summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/ffmpeg/CVS/Entries4
-rw-r--r--graphics/ffmpeg/CVS/Repository1
-rw-r--r--graphics/ffmpeg/Makefile215
-rw-r--r--graphics/ffmpeg/distinfo2
-rw-r--r--graphics/ffmpeg/patches/CVS/Entries25
-rw-r--r--graphics/ffmpeg/patches/CVS/Repository1
-rw-r--r--graphics/ffmpeg/patches/patch-configure81
-rw-r--r--graphics/ffmpeg/patches/patch-doc_encoders_texi103
-rw-r--r--graphics/ffmpeg/patches/patch-ffbuild_library_mak21
-rw-r--r--graphics/ffmpeg/patches/patch-ffbuild_pkgconfig_generate_sh33
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aacenc_c14
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_fft_neon_S44
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_h264idct_neon_S35
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_mdct_neon_S61
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_simple_idct_neon_S12
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_synth_filter_neon_S19
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_16bpp_neon_S129
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_neon_S120
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_16bpp_neon_S174
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_neon_S220
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_libaomenc_c218
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c389
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_version_h14
-rw-r--r--graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm128
-rw-r--r--graphics/ffmpeg/patches/patch-libavformat_rtpproto_c14
-rw-r--r--graphics/ffmpeg/patches/patch-libavformat_udp_c82
-rw-r--r--graphics/ffmpeg/patches/patch-libavformat_utils_c24
-rw-r--r--graphics/ffmpeg/patches/patch-libavutil_aarch64_asm_S137
-rw-r--r--graphics/ffmpeg/patches/patch-libavutil_x86_x86inc_asm27
-rw-r--r--graphics/ffmpeg/patches/patch-libswscale_ppc_yuv2rgb_altivec_c14
-rw-r--r--graphics/ffmpeg/pkg/CVS/Entries4
-rw-r--r--graphics/ffmpeg/pkg/CVS/Repository1
-rw-r--r--graphics/ffmpeg/pkg/DESCR2
-rw-r--r--graphics/ffmpeg/pkg/PLIST249
-rw-r--r--graphics/ffmpeg/pkg/README18
35 files changed, 2635 insertions, 0 deletions
diff --git a/graphics/ffmpeg/CVS/Entries b/graphics/ffmpeg/CVS/Entries
new file mode 100644
index 0000000..d57ed9a
--- /dev/null
+++ b/graphics/ffmpeg/CVS/Entries
@@ -0,0 +1,4 @@
1D/patches////
2D/pkg////
3/distinfo/1.66/Sun Apr 30 07:19:22 2023//
4/Makefile/1.237/Mon Dec 18 18:19:44 2023//
diff --git a/graphics/ffmpeg/CVS/Repository b/graphics/ffmpeg/CVS/Repository
new file mode 100644
index 0000000..4aa832b
--- /dev/null
+++ b/graphics/ffmpeg/CVS/Repository
@@ -0,0 +1 @@
ports/graphics/ffmpeg
diff --git a/graphics/ffmpeg/Makefile b/graphics/ffmpeg/Makefile
new file mode 100644
index 0000000..f1cb349
--- /dev/null
+++ b/graphics/ffmpeg/Makefile
@@ -0,0 +1,215 @@
1COMMENT= audio/video converter and streamer
2
3V= 4.4.4
4DISTNAME= ffmpeg-${V}
5EPOCH= 1
6REVISION= 3
7CATEGORIES= graphics multimedia
8SITES= https://ffmpeg.org/releases/
9EXTRACT_SUFX= .tar.xz
10
11USE_NOBTCFI-amd64= Yes
12
13SHARED_LIBS= avcodec 25.0 \
14 avdevice 13.0 \
15 avfilter 11.0 \
16 avformat 22.0 \
17 avutil 15.0 \
18 postproc 19.0 \
19 swresample 4.0 \
20 swscale 7.0
21
22HOMEPAGE= https://ffmpeg.org/
23
24MAINTAINER= Brad Smith <brad@comstyle.com>
25
26# LGPLv2.1 and GPLv2
27PERMIT_PACKAGE= Yes
28
29WANTLIB+= SDL2 X11 Xext Xv aom ass bz2 c crypto dav1d fontconfig
30WANTLIB+= freetype fribidi gsm iconv lzma m mp3lame opus
31WANTLIB+= pthread sndio speex ssl theoradec theoraenc v4l2
32WANTLIB+= vorbis vorbisenc vpx x264 x265 xcb xcb-shape xcb-shm
33WANTLIB+= xcb-xfixes xml2 xvidcore vidstab z zimg
34
35COMPILER= base-clang ports-gcc
36COMPILER_LANGS= c
37
38DEBUG_PACKAGES= ${BUILD_PACKAGES}
39
40BUILD_DEPENDS= audio/ladspa \
41 textproc/texi2html \
42 multimedia/frei0r-plugins
43.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
44BUILD_DEPENDS+= devel/nasm
45.endif
46LIB_DEPENDS= archivers/bzip2 \
47 archivers/xz \
48 audio/lame \
49 audio/libvorbis \
50 audio/opus \
51 audio/speex \
52 audio/gsm \
53 converters/libiconv \
54 devel/sdl2 \
55 graphics/zimg \
56 multimedia/aom \
57 multimedia/dav1d \
58 multimedia/libass \
59 multimedia/libtheora \
60 multimedia/libv4l \
61 multimedia/libvidstab \
62 multimedia/libvpx \
63 multimedia/x264 \
64 multimedia/x265 \
65 multimedia/xvidcore \
66 textproc/libxml
67
68# inter-library dependencies for the current configuration
69LIBavcodec_EXTRALIBS=-L${LOCALBASE}/lib -laom -ldav1d -lgsm -liconv -llzma -lmp3lame -lopus -lspeex -ltheoradec -ltheoraenc -lvorbis -lvorbisenc -lvpx -lx264 -lx265 -lxvidcore -lm -lz -pthread
70LIBavdevice_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -lX11 -lXext -lXv -lxcb-shape -lxcb-shm -lxcb-xfixes -lxcb -lsndio -lv4l2 -lm
71LIBavfilter_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -lass -lfontconfig -lfreetype -lfribidi -lvidstab -lm -lz -lzimg -pthread
72LIBavformat_EXTRALIBS=-L${LOCALBASE}/lib -lbz2 -lxml2 -lssl -lcrypto -lm -lz
73LIBavutil_EXTRALIBS=-lm -pthread
74LIBpostproc_EXTRALIBS=-lm
75LIBswresample_EXTRALIBS=-lm
76LIBswscale_EXTRALIBS=-lm
77
78.if ${MACHINE_ARCH} == i386
79LDLIBFLAGS+= -Wl,-znotext
80.endif
81
82OPTFLAGS= ${CFLAGS}
83
84# until the system headers are fixed properly.
85OPTFLAGS+= -Wno-redundant-decls
86
87FIX_EXTRACT_PERMISSIONS= Yes
88SEPARATE_BUILD= Yes
89USE_GMAKE= Yes
90CONFIGURE_STYLE= simple
91CONFIGURE_ARGS+=--enable-shared \
92 --arch=${MACHINE_ARCH} \
93 --cc=${CC} \
94 --enable-debug \
95 --disable-stripping \
96 --disable-indev=jack \
97 --disable-outdev=sdl2 \
98 --enable-fontconfig \
99 --enable-frei0r \
100 --enable-gpl \
101 --enable-ladspa \
102 --enable-libaom \
103 --enable-libass \
104 --enable-libdav1d \
105 --enable-libfreetype \
106 --enable-libfribidi \
107 --enable-libgsm \
108 --enable-libmp3lame \
109 --enable-libopus \
110 --enable-libspeex \
111 --enable-libtheora \
112 --enable-libv4l2 \
113 --enable-libvorbis \
114 --enable-libvpx \
115 --enable-libx264 \
116 --enable-libx265 \
117 --enable-libxml2 \
118 --enable-libxvid \
119 --enable-libzimg \
120 --enable-nonfree \
121 --enable-openssl \
122 --enable-libvidstab \
123 --extra-cflags="-I${LOCALBASE}/include -I${X11BASE}/include" \
124 --extra-libs="-L${LOCALBASE}/lib -L${X11BASE}/lib" \
125 --extra-ldsoflags="${LDLIBFLAGS}" \
126 --mandir=${PREFIX}/man \
127 --objcc="/usr/bin/false" \
128 --optflags="${OPTFLAGS}"
129
130.if ${MACHINE_ARCH} == "arm"
131CONFIGURE_ARGS+=--disable-asm
132.endif
133.if ${MACHINE_ARCH} == "powerpc"
134CONFIGURE_ARGS+=--disable-altivec
135.endif
136.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
137CONFIGURE_ARGS+=--disable-mipsdsp \
138 --disable-mipsdspr2 \
139 --disable-mipsfpu \
140 --disable-mmi \
141 --disable-msa
142.endif
143
144CONFIGURE_ENV+= TERM=${TERM} \
145 TMPDIR=${WRKBUILD} \
146 X86ASMFLAGS="${DEBUG}"
147
148MAKE_ENV+= V=1 \
149 libavcodec_extralibs="${LIBavcodec_EXTRALIBS}" \
150 libavdevice_extralibs="${LIBavdevice_EXTRALIBS}" \
151 libavfilter_extralibs="${LIBavfilter_EXTRALIBS}" \
152 libavformat_extralibs="${LIBavformat_EXTRALIBS}" \
153 libavutil_extralibs="${LIBavutil_EXTRALIBS}" \
154 libpostproc_extralibs="${LIBpostproc_EXTRALIBS}" \
155 libswresample_extralibs="${LIBswresample_EXTRALIBS}" \
156 libswscale_extralibs="${LIBswscale_EXTRALIBS}" \
157 libavcodec_linkflags="-Wl,-rpath-link,${LOCALBASE}/lib" \
158 libavdevice_linkflags="-Wl,-rpath-link,${LOCALBASE}/lib:${X11BASE}/lib" \
159 libavfilter_linkflags="-Wl,-rpath-link,${LOCALBASE}/lib:${X11BASE}/lib" \
160 libavformat_linkflags="-Wl,-rpath-link,${LOCALBASE}/lib" \
161 libavutil_linkflags="" \
162 libpostproc_linkflags="" \
163 libswresample_linkflags="" \
164 libswscale_linkflags="" \
165 libavcodec_requires="libswresample libavutil" \
166 libavdevice_requires="libavfilter libswscale libpostproc libavformat libavcodec libswresample libavutil" \
167 libavfilter_requires="libswscale libpostproc libavformat libavcodec libswresample libavutil" \
168 libavformat_requires="libavcodec libswresample libavutil" \
169 libavutil_requires="" \
170 libpostproc_requires="libavutil" \
171 libswresample_requires="libavutil" \
172 libswscale_requires="libavutil"
173
174VERSION_FLAGS= libavcodec_VERSION=${LIBavcodec_VERSION} \
175 libavdevice_VERSION=${LIBavdevice_VERSION} \
176 libavfilter_VERSION=${LIBavfilter_VERSION} \
177 libavformat_VERSION=${LIBavformat_VERSION} \
178 libavutil_VERSION=${LIBavutil_VERSION} \
179 libpostproc_VERSION=${LIBpostproc_VERSION} \
180 libswresample_VERSION=${LIBswresample_VERSION} \
181 libswscale_VERSION=${LIBswscale_VERSION}
182
183MAKE_FLAGS= ${VERSION_FLAGS} \
184 LIBavcodec_EXTRALIBS="-lswresample -lavutil ${LIBavcodec_EXTRALIBS}" \
185 LIBavdevice_EXTRALIBS="-lavfilter -lswscale -lpostproc -lavformat -lavcodec -lswresample -lavutil ${LIBavdevice_EXTRALIBS}" \
186 LIBavfilter_EXTRALIBS="-lswscale -lpostproc -lavformat -lavcodec -lswresample -lavutil ${LIBavfilter_EXTRALIBS}" \
187 LIBavformat_EXTRALIBS="-lavcodec -lswresample -lavutil ${LIBavformat_EXTRALIBS}" \
188 LIBavutil_EXTRALIBS="${LIBavutil_EXTRALIBS}" \
189 LIBpostproc_EXTRALIBS="-lavutil ${LIBpostproc_EXTRALIBS}" \
190 LIBswresample_EXTRALIBS="-lavutil ${LIBswresample_EXTRALIBS}" \
191 LIBswscale_EXTRALIBS="-lavutil ${LIBswscale_EXTRALIBS}"
192FAKE_FLAGS= ${VERSION_FLAGS} \
193 LDCONFIG=true
194
195ALL_TARGET= all tools/qt-faststart
196TEST_TARGET= check
197
198.for _l in avutil avfilter avcodec avformat avdevice swscale swresample postproc
199TEST_LIB_PATH:= ${TEST_LIB_PATH}:${WRKBUILD}/lib${_l}
200.endfor
201TEST_ENV+= LD_LIBRARY_PATH=${TEST_LIB_PATH:C/^://}
202
203HTML_DOCS= developer faq ffmpeg ffplay ffprobe general libavfilter
204
205post-install:
206 ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ffmpeg
207 ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/ffmpeg
208 ${INSTALL_PROGRAM} ${WRKBUILD}/tools/qt-faststart ${PREFIX}/bin
209.for doc in ${HTML_DOCS}
210 ${INSTALL_DATA} ${WRKBUILD}/doc/${doc}.html ${PREFIX}/share/doc/ffmpeg
211.endfor
212 mv -f ${PREFIX}/share/ffmpeg/examples/* ${PREFIX}/share/examples/ffmpeg
213 -rmdir ${PREFIX}/share/ffmpeg/examples
214
215.include <bsd.port.mk>
diff --git a/graphics/ffmpeg/distinfo b/graphics/ffmpeg/distinfo
new file mode 100644
index 0000000..a3c4508
--- /dev/null
+++ b/graphics/ffmpeg/distinfo
@@ -0,0 +1,2 @@
1SHA256 (ffmpeg-4.4.4.tar.xz) = 6As4DVlcgJBg9m+WpdhJUR70p2omt26s9XeLlMNXAwk=
2SIZE (ffmpeg-4.4.4.tar.xz) = 9565584
diff --git a/graphics/ffmpeg/patches/CVS/Entries b/graphics/ffmpeg/patches/CVS/Entries
new file mode 100644
index 0000000..ae0844d
--- /dev/null
+++ b/graphics/ffmpeg/patches/CVS/Entries
@@ -0,0 +1,25 @@
1/patch-ffbuild_library_mak/1.2/Sat Mar 12 08:16:31 2022//
2/patch-ffbuild_pkgconfig_generate_sh/1.2/Sat Mar 12 08:16:31 2022//
3/patch-libavcodec_aacenc_c/1.25/Sat Mar 12 08:16:31 2022//
4/patch-libavformat_rtpproto_c/1.2/Sat Mar 12 08:16:31 2022//
5/patch-libavformat_udp_c/1.2/Sat Mar 12 08:16:31 2022//
6/patch-libswscale_ppc_yuv2rgb_altivec_c/1.2/Sat Mar 12 08:16:31 2022//
7/patch-doc_encoders_texi/1.7/Fri May 13 17:17:34 2022//
8/patch-libavcodec_version_h/1.1/Fri May 13 12:56:19 2022//
9/patch-libavcodec_libaomenc_c/1.5/Sat Aug 20 17:16:46 2022//
10/patch-configure/1.72/Mon Dec 5 08:18:47 2022//
11/patch-libavcodec_libsvtav1_c/1.3/Mon Dec 5 18:17:28 2022//
12/patch-libavcodec_aarch64_fft_neon_S/1.1/Sat Jun 17 22:19:43 2023//
13/patch-libavcodec_aarch64_h264idct_neon_S/1.1/Sat Jun 17 22:19:43 2023//
14/patch-libavcodec_aarch64_mdct_neon_S/1.1/Sat Jun 17 22:19:43 2023//
15/patch-libavcodec_aarch64_simple_idct_neon_S/1.1/Sat Jun 17 22:19:43 2023//
16/patch-libavcodec_aarch64_synth_filter_neon_S/1.1/Sat Jun 17 22:19:43 2023//
17/patch-libavcodec_aarch64_vp9itxfm_16bpp_neon_S/1.1/Sat Jun 17 22:19:43 2023//
18/patch-libavcodec_aarch64_vp9itxfm_neon_S/1.1/Sat Jun 17 22:19:43 2023//
19/patch-libavcodec_aarch64_vp9lpf_16bpp_neon_S/1.1/Sat Jun 17 22:19:43 2023//
20/patch-libavcodec_aarch64_vp9lpf_neon_S/1.1/Sat Jun 17 22:19:43 2023//
21/patch-libavutil_aarch64_asm_S/1.1/Sat Jun 17 22:19:43 2023//
22/patch-libavcodec_x86_fft_asm/1.2/Wed Jun 21 17:19:19 2023//
23/patch-libavutil_x86_x86inc_asm/1.3/Wed Jun 21 12:58:18 2023//
24/patch-libavformat_utils_c/1.7/Tue Dec 19 18:19:46 2023//
25D
diff --git a/graphics/ffmpeg/patches/CVS/Repository b/graphics/ffmpeg/patches/CVS/Repository
new file mode 100644
index 0000000..19f1d84
--- /dev/null
+++ b/graphics/ffmpeg/patches/CVS/Repository
@@ -0,0 +1 @@
ports/graphics/ffmpeg/patches
diff --git a/graphics/ffmpeg/patches/patch-configure b/graphics/ffmpeg/patches/patch-configure
new file mode 100644
index 0000000..b269885
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-configure
@@ -0,0 +1,81 @@
1- configure: use pkg-config for sndio
2- configure: add initial RISC-V support
3- Fix broken libatomic test
4
5Index: configure
6--- configure.orig
7+++ configure
8@@ -1992,6 +1992,7 @@ ARCH_LIST="
9 parisc
10 ppc
11 ppc64
12+ riscv
13 s390
14 sh4
15 sparc
16@@ -2601,7 +2602,7 @@ for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD);
17 done
18
19 aligned_stack_if_any="aarch64 ppc x86"
20-fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
21+fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 riscv64 sparc64 x86_64"
22 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
23 fast_unaligned_if_any="aarch64 ppc x86"
24 simd_align_16_if_any="altivec neon sse"
25@@ -4915,6 +4916,9 @@ case "$arch" in
26 "Power Macintosh"|ppc*|powerpc*)
27 arch="ppc"
28 ;;
29+ riscv*)
30+ arch="riscv"
31+ ;;
32 s390|s390x)
33 arch="s390"
34 ;;
35@@ -5306,6 +5310,10 @@ case "$arch" in
36 check_64bit ppc ppc64
37 enabled shared && enable_weak pic
38 ;;
39+ riscv)
40+ check_64bit riscv32 riscv64
41+ enabled shared && enable_weak pic
42+ ;;
43 s390)
44 check_64bit s390 s390x
45 enabled shared && enable_weak pic
46@@ -5378,7 +5386,6 @@ case $target_os in
47 enable section_data_rel_ro
48 striptype=""
49 SHFLAGS='-shared'
50- SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
51 SLIB_INSTALL_LINKS=
52 oss_indev_extralibs="-lossaudio"
53 oss_outdev_extralibs="-lossaudio"
54@@ -5734,7 +5741,7 @@ set_default libdir
55 set_default $PATHS_LIST
56 set_default nm
57
58-disabled optimizations || enabled ossfuzz || check_cflags -fomit-frame-pointer
59+enabled x86_32 && check_cflags -fomit-frame-pointer
60
61 enable_weak_pic() {
62 disabled pic && return
63@@ -6189,7 +6196,7 @@ check_headers asm/types.h
64 #
65 # some configurations also require linking to libatomic, so try
66 # both with -latomic and without
67-for LATOMIC in "-latomic" ""; do
68+for LATOMIC in "" "-latomic"; do
69 check_builtin stdatomic stdatomic.h \
70 "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar" \
71 $LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
72@@ -6657,7 +6664,8 @@ enabled alsa && { check_pkg_config alsa alsa "alsa/aso
73 enabled libjack &&
74 require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
75
76-enabled sndio && check_lib sndio sndio.h sio_open -lsndio
77+enabled sndio && { check_pkg_config sndio sndio "sndio.h" sio_open ||
78+ check_lib sndio sndio.h sio_open -lsndio; }
79
80 if enabled libcdio; then
81 check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open ||
diff --git a/graphics/ffmpeg/patches/patch-doc_encoders_texi b/graphics/ffmpeg/patches/patch-doc_encoders_texi
new file mode 100644
index 0000000..e6bc54d
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-doc_encoders_texi
@@ -0,0 +1,103 @@
1- doc/encoders: update default coder for aac
2- doc/encoders: add available values for libsvtav1 options
3- avcodec/libsvtav1: add a svtav1-params option to pass a list of key=value
4 parameters
5- avcodec/libsvtav1: update some options and defaults
6
7Index: doc/encoders.texi
8--- doc/encoders.texi.orig
9+++ doc/encoders.texi
10@@ -53,7 +53,7 @@ Set AAC encoder coding method. Possible values:
11
12 @table @samp
13 @item twoloop
14-Two loop searching (TLS) method.
15+Two loop searching (TLS) method. This is the default method.
16
17 This method first sets quantizers depending on band thresholds and then tries
18 to find an optimal combination by adding or subtracting a specific value from
19@@ -75,7 +75,6 @@ Constant quantizer method.
20 Uses a cheaper version of twoloop algorithm that doesn't try to do as many
21 clever adjustments. Worse with low bitrates (less than 64kbps), but is better
22 and much faster at higher bitrates.
23-This is the default choice for a coder
24
25 @end table
26
27@@ -1747,27 +1746,29 @@ You need to explicitly configure the build with @code{
28 @table @option
29 @item profile
30 Set the encoding profile.
31+@table @samp
32+@item main
33+@item high
34+@item professional
35+@end table
36
37 @item level
38-Set the operating point level.
39+Set the operating point level. For example: '4.0'
40
41+@item hielevel
42+Set the Hierarchical prediction levels.
43+@table @samp
44+@item 3level
45+@item 4level
46+This is the default.
47+@end table
48+
49 @item tier
50 Set the operating point tier.
51-
52-@item rc
53-Set the rate control mode to use.
54-
55-Possible modes:
56-@table @option
57-@item cqp
58-Constant quantizer: use fixed values of qindex (dependent on the frame type)
59-throughout the stream. This mode is the default.
60-
61-@item vbr
62-Variable bitrate: use a target bitrate for the whole stream.
63-
64-@item cvbr
65-Constrained variable bitrate: use a target bitrate for each GOP.
66+@table @samp
67+@item main
68+This is the default.
69+@item high
70 @end table
71
72 @item qmax
73@@ -1776,6 +1777,9 @@ Set the maximum quantizer to use when using a bitrate
74 @item qmin
75 Set the minimum quantizer to use when using a bitrate mode.
76
77+@item crf
78+Constant rate factor value used in crf rate control mode (0-63).
79+
80 @item qp
81 Set the quantizer used in cqp rate control mode (0-63).
82
83@@ -1786,14 +1790,18 @@ Enable scene change detection.
84 Set number of frames to look ahead (0-120).
85
86 @item preset
87-Set the quality-speed tradeoff, in the range 0 to 8. Higher values are
88-faster but lower quality. Defaults to 8 (highest speed).
89+Set the quality-speed tradeoff, in the range 0 to 13. Higher values are
90+faster but lower quality.
91
92 @item tile_rows
93 Set log2 of the number of rows of tiles to use (0-6).
94
95 @item tile_columns
96 Set log2 of the number of columns of tiles to use (0-4).
97+
98+@item svtav1-params
99+Set SVT-AV1 options using a list of @var{key}=@var{value} pairs separated
100+by ":". See the SVT-AV1 encoder user guide for a list of accepted parameters.
101
102 @end table
103
diff --git a/graphics/ffmpeg/patches/patch-ffbuild_library_mak b/graphics/ffmpeg/patches/patch-ffbuild_library_mak
new file mode 100644
index 0000000..d44a459
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-ffbuild_library_mak
@@ -0,0 +1,21 @@
1Index: ffbuild/library.mak
2--- ffbuild/library.mak.orig
3+++ ffbuild/library.mak
4@@ -50,7 +50,7 @@ $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
5
6 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
7 $(SLIB_CREATE_DEF_CMD)
8- $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
9+ $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(LIB$(NAME)_EXTRALIBS)
10 $(SLIB_EXTRA_CMD)
11
12 ifdef SUBDIR
13@@ -64,8 +64,6 @@ clean::
14 install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
15 $(Q)mkdir -p "$(SHLIBDIR)"
16 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
17- $$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
18- $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));)
19 $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
20 $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
21 $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
diff --git a/graphics/ffmpeg/patches/patch-ffbuild_pkgconfig_generate_sh b/graphics/ffmpeg/patches/patch-ffbuild_pkgconfig_generate_sh
new file mode 100644
index 0000000..b8097e7
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-ffbuild_pkgconfig_generate_sh
@@ -0,0 +1,33 @@
1Index: ffbuild/pkgconfig_generate.sh
2--- ffbuild/pkgconfig_generate.sh.orig
3+++ ffbuild/pkgconfig_generate.sh
4@@ -12,7 +12,7 @@ shortname=$1
5 name=lib${shortname}
6 fullname=${name}${build_suffix}
7 comment=$2
8-libs=$(eval echo \$extralibs_${shortname})
9+libs=$(eval echo \$${name}_extralibs)
10 deps=$(eval echo \$${shortname}_deps)
11
12 for dep in $deps; do
13@@ -20,9 +20,9 @@ for dep in $deps; do
14 fulldepname=${depname}${build_suffix}
15 . ${depname}/${depname}.version
16 depversion=$(eval echo \$${depname}_VERSION)
17- requires="$requires ${fulldepname} >= ${depversion}, "
18 done
19-requires=${requires%, }
20+requires=$(eval echo \$${name}_requires)
21+linkflags=$(eval echo \$${name}_linkflags)
22
23 version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2)
24
25@@ -38,7 +38,7 @@ Version: $version
26 Requires: $($shared || echo $requires)
27 Requires.private: $($shared && echo $requires)
28 Conflicts:
29-Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs)
30+Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs) $linkflags
31 Libs.private: $($shared && echo $libs)
32 Cflags: -I\${includedir}
33 EOF
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aacenc_c b/graphics/ffmpeg/patches/patch-libavcodec_aacenc_c
new file mode 100644
index 0000000..7f8b36f
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aacenc_c
@@ -0,0 +1,14 @@
1aacenc: make the twoloop coder the default
2
3Index: libavcodec/aacenc.c
4--- libavcodec/aacenc.c.orig
5+++ libavcodec/aacenc.c
6@@ -1104,7 +1104,7 @@ static av_cold int aac_encode_init(AVCodecContext *avc
7
8 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
9 static const AVOption aacenc_options[] = {
10- {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_FAST}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "coder"},
11+ {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "coder"},
12 {"anmr", "ANMR method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
13 {"twoloop", "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
14 {"fast", "Default fast search", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_fft_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_fft_neon_S
new file mode 100644
index 0000000..4e1e646
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_fft_neon_S
@@ -0,0 +1,44 @@
1Index: libavcodec/aarch64/fft_neon.S
2--- libavcodec/aarch64/fft_neon.S.orig
3+++ libavcodec/aarch64/fft_neon.S
4@@ -36,6 +36,7 @@
5
6
7 function fft4_neon
8+ AARCH64_VALID_JUMP_TARGET
9 ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
10
11 fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1
12@@ -58,6 +59,7 @@ function fft4_neon
13 endfunc
14
15 function fft8_neon
16+ AARCH64_VALID_JUMP_TARGET
17 mov x1, x0
18 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
19 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
20@@ -108,6 +110,7 @@ function fft8_neon
21 endfunc
22
23 function fft16_neon
24+ AARCH64_VALID_JUMP_TARGET
25 mov x1, x0
26 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
27 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32
28@@ -337,6 +340,8 @@ endfunc
29
30 .macro def_fft n, n2, n4
31 function fft\n\()_neon, align=6
32+ AARCH64_VALID_JUMP_TARGET
33+ AARCH64_SIGN_LINK_REGISTER
34 sub sp, sp, #16
35 stp x28, x30, [sp]
36 add x28, x0, #\n4*2*8
37@@ -347,6 +352,7 @@ function fft\n\()_neon, align=6
38 bl fft\n4\()_neon
39 sub x0, x28, #\n4*2*8
40 ldp x28, x30, [sp], #16
41+ AARCH64_VALIDATE_LINK_REGISTER
42 movrel x4, X(ff_cos_\n)
43 mov x2, #\n4>>1
44 b fft_pass_neon
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_h264idct_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_h264idct_neon_S
new file mode 100644
index 0000000..7626200
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_h264idct_neon_S
@@ -0,0 +1,35 @@
1Index: libavcodec/aarch64/h264idct_neon.S
2--- libavcodec/aarch64/h264idct_neon.S.orig
3+++ libavcodec/aarch64/h264idct_neon.S
4@@ -24,6 +24,7 @@
5
6 function ff_h264_idct_add_neon, export=1
7 .L_ff_h264_idct_add_neon:
8+ AARCH64_VALID_CALL_TARGET
9 ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1]
10 sxtw x2, w2
11 movi v30.8H, #0
12@@ -79,6 +80,7 @@ endfunc
13
14 function ff_h264_idct_dc_add_neon, export=1
15 .L_ff_h264_idct_dc_add_neon:
16+ AARCH64_VALID_CALL_TARGET
17 sxtw x2, w2
18 mov w3, #0
19 ld1r {v2.8H}, [x1]
20@@ -266,6 +268,7 @@ endfunc
21
22 function ff_h264_idct8_add_neon, export=1
23 .L_ff_h264_idct8_add_neon:
24+ AARCH64_VALID_CALL_TARGET
25 movi v19.8H, #0
26 sxtw x2, w2
27 ld1 {v24.8H, v25.8H}, [x1]
28@@ -330,6 +333,7 @@ endfunc
29
30 function ff_h264_idct8_dc_add_neon, export=1
31 .L_ff_h264_idct8_dc_add_neon:
32+ AARCH64_VALID_CALL_TARGET
33 mov w3, #0
34 sxtw x2, w2
35 ld1r {v31.8H}, [x1]
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_mdct_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_mdct_neon_S
new file mode 100644
index 0000000..9d52877
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_mdct_neon_S
@@ -0,0 +1,61 @@
1Index: libavcodec/aarch64/mdct_neon.S
2--- libavcodec/aarch64/mdct_neon.S.orig
3+++ libavcodec/aarch64/mdct_neon.S
4@@ -25,6 +25,7 @@
5 function ff_imdct_half_neon, export=1
6 sub sp, sp, #32
7 stp x19, x20, [sp]
8+ AARCH64_SIGN_LINK_REGISTER
9 str x30, [sp, #16]
10 mov x12, #1
11 ldr w14, [x0, #28] // mdct_bits
12@@ -121,6 +122,7 @@ function ff_imdct_half_neon, export=1
13
14 ldp x19, x20, [sp]
15 ldr x30, [sp, #16]
16+ AARCH64_VALIDATE_LINK_REGISTER
17 add sp, sp, #32
18
19 ret
20@@ -129,6 +131,7 @@ endfunc
21 function ff_imdct_calc_neon, export=1
22 sub sp, sp, #32
23 stp x19, x20, [sp]
24+ AARCH64_SIGN_LINK_REGISTER
25 str x30, [sp, #16]
26 ldr w3, [x0, #28] // mdct_bits
27 mov x19, #1
28@@ -160,8 +163,10 @@ function ff_imdct_calc_neon, export=1
29 subs x19, x19, #16
30 b.gt 1b
31
32- ldp x19, x20, [sp], #16
33- ldr x30, [sp], #16
34+ ldp x19, x20, [sp]
35+ ldr x30, [sp, #16]
36+ AARCH64_VALIDATE_LINK_REGISTER
37+ add sp, sp, #32
38
39 ret
40 endfunc
41@@ -170,6 +175,7 @@ endfunc
42 function ff_mdct_calc_neon, export=1
43 sub sp, sp, #32
44 stp x19, x20, [sp]
45+ AARCH64_SIGN_LINK_REGISTER
46 str x30, [sp, #16]
47
48 mov x12, #1
49@@ -317,7 +323,10 @@ function ff_mdct_calc_neon, export=1
50 st2 {v4.2s,v5.2s}, [x0]
51 st2 {v6.2s,v7.2s}, [x8]
52
53- ldp x19, x20, [sp], #16
54- ldr x30, [sp], #16
55+ ldp x19, x20, [sp]
56+ ldr x30, [sp, #16]
57+ AARCH64_VALIDATE_LINK_REGISTER
58+ add sp, sp, #32
59+
60 ret
61 endfunc
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_simple_idct_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_simple_idct_neon_S
new file mode 100644
index 0000000..eda8f6e
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_simple_idct_neon_S
@@ -0,0 +1,12 @@
1Index: libavcodec/aarch64/simple_idct_neon.S
2--- libavcodec/aarch64/simple_idct_neon.S.orig
3+++ libavcodec/aarch64/simple_idct_neon.S
4@@ -58,7 +58,7 @@ endconst
5 .endm
6
7 .macro idct_end
8- br x10
9+ ret x10
10 .endm
11
12 .macro smull1 a, b, c
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_synth_filter_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_synth_filter_neon_S
new file mode 100644
index 0000000..3798818
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_synth_filter_neon_S
@@ -0,0 +1,19 @@
1Index: libavcodec/aarch64/synth_filter_neon.S
2--- libavcodec/aarch64/synth_filter_neon.S.orig
3+++ libavcodec/aarch64/synth_filter_neon.S
4@@ -52,6 +52,7 @@ function ff_synth_filter_float_neon, export=1
5 stp x5, x1, [sp, #16]
6 and x7, x7, #~63
7 and w8, w8, #511
8+ AARCH64_SIGN_LINK_REGISTER
9 stp x7, x30, [sp, #32]
10 str w8, [x2]
11 str s0, [sp, #48]
12@@ -63,6 +64,7 @@ function ff_synth_filter_float_neon, export=1
13 ldp x2, x4, [sp] // synct_buf_2, window
14 ldp x13, x9, [sp, #16] // out, synth_buf
15 ldp x0, x30, [sp, #32] // *synth_buf_offset
16+ AARCH64_VALIDATE_LINK_REGISTER
17 ldr s0, [sp, #48]
18
19 add x3, x2, #16*4 // synct_buf_2 + 16
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_16bpp_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_16bpp_neon_S
new file mode 100644
index 0000000..c7866a3
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_16bpp_neon_S
@@ -0,0 +1,129 @@
1Index: libavcodec/aarch64/vp9itxfm_16bpp_neon.S
2--- libavcodec/aarch64/vp9itxfm_16bpp_neon.S.orig
3+++ libavcodec/aarch64/vp9itxfm_16bpp_neon.S
4@@ -1040,7 +1040,7 @@ function \txfm\()16_1d_4x16_pass1_neon
5 .irp i, 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31
6 store \i, x0, #16
7 .endr
8- br x14
9+ ret x14
10 1:
11 // Special case: For the last input column (x1 == 12),
12 // which would be stored as the last row in the temp buffer,
13@@ -1068,7 +1068,7 @@ function \txfm\()16_1d_4x16_pass1_neon
14 mov v29.16b, v17.16b
15 mov v30.16b, v18.16b
16 mov v31.16b, v19.16b
17- br x14
18+ ret x14
19 endfunc
20
21 // Read a vertical 4x16 slice out of a 16x16 matrix, do a transform on it,
22@@ -1098,7 +1098,7 @@ function \txfm\()16_1d_4x16_pass2_neon
23 load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s
24 load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s
25
26- br x14
27+ ret x14
28 endfunc
29 .endm
30
31@@ -1208,7 +1208,7 @@ function vp9_\txfm1\()_\txfm2\()_16x16_add_16_neon
32 ldp d12, d13, [sp], 0x10
33 ldp d14, d15, [sp], 0x10
34 .endif
35- br x15
36+ ret x15
37 endfunc
38
39 function ff_vp9_\txfm1\()_\txfm2\()_16x16_add_10_neon, export=1
40@@ -1264,7 +1264,7 @@ function idct16_1d_4x16_pass1_quarter_neon
41 st1 {v23.4s}, [x0], #16
42 st1 {v27.4s}, [x0], #16
43 st1 {v31.4s}, [x0], #16
44- br x14
45+ ret x14
46 endfunc
47
48 function idct16_1d_4x16_pass2_quarter_neon
49@@ -1286,7 +1286,7 @@ function idct16_1d_4x16_pass2_quarter_neon
50 load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s
51 load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s
52
53- br x14
54+ ret x14
55 endfunc
56
57 function idct16_1d_4x16_pass1_half_neon
58@@ -1313,7 +1313,7 @@ function idct16_1d_4x16_pass1_half_neon
59 .irp i, 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31
60 store \i, x0, #16
61 .endr
62- br x14
63+ ret x14
64 1:
65 // Special case: For the second input column (r1 == 4),
66 // which would be stored as the second row in the temp buffer,
67@@ -1341,7 +1341,7 @@ function idct16_1d_4x16_pass1_half_neon
68 mov v21.16b, v17.16b
69 mov v22.16b, v18.16b
70 mov v23.16b, v19.16b
71- br x14
72+ ret x14
73 endfunc
74
75 function idct16_1d_4x16_pass2_half_neon
76@@ -1364,7 +1364,7 @@ function idct16_1d_4x16_pass2_half_neon
77 load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s
78 load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s
79
80- br x14
81+ ret x14
82 endfunc
83
84 .macro idct16_partial size
85@@ -1390,7 +1390,7 @@ function idct16x16_\size\()_add_16_neon
86
87 add sp, sp, #1024
88 ldp d8, d9, [sp], 0x10
89- br x15
90+ ret x15
91 endfunc
92 .endm
93
94@@ -1729,7 +1729,7 @@ function idct32_1d_4x32_pass1\suffix\()_neon
95 store_rev v29.4s, v25.4s, v21.4s, v17.4s, v29.16b, v25.16b
96 store_rev v28.4s, v24.4s, v20.4s, v16.4s, v28.16b, v24.16b
97 .purgem store_rev
98- br x14
99+ ret x14
100 endfunc
101
102 // This is mostly the same as 4x32_pass1, but without the transpose,
103@@ -1849,7 +1849,7 @@ function idct32_1d_4x32_pass2\suffix\()_neon
104 load_acc_store v24.4s, v25.4s, v26.4s, v27.4s, 1
105 load_acc_store v28.4s, v29.4s, v30.4s, v31.4s, 1
106 .purgem load_acc_store
107- br x14
108+ ret x14
109 endfunc
110 .endm
111
112@@ -1943,7 +1943,7 @@ function vp9_idct_idct_32x32_add_16_neon
113 ldp d10, d11, [sp], 0x10
114 ldp d8, d9, [sp], 0x10
115
116- br x15
117+ ret x15
118 endfunc
119
120 function ff_vp9_idct_idct_32x32_add_10_neon, export=1
121@@ -2009,7 +2009,7 @@ function idct32x32_\size\()_add_16_neon
122 ldp d10, d11, [sp], 0x10
123 ldp d8, d9, [sp], 0x10
124
125- br x15
126+ ret x15
127 endfunc
128 .endm
129
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_neon_S
new file mode 100644
index 0000000..2c9dc19
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9itxfm_neon_S
@@ -0,0 +1,120 @@
1Index: libavcodec/aarch64/vp9itxfm_neon.S
2--- libavcodec/aarch64/vp9itxfm_neon.S.orig
3+++ libavcodec/aarch64/vp9itxfm_neon.S
4@@ -787,7 +787,7 @@ function \txfm\()16_1d_8x16_pass1_neon
5 .irp i, 16, 24, 17, 25, 18, 26, 19, 27, 20, 28, 21, 29, 22, 30, 23, 31
6 store \i, x0, #16
7 .endr
8- br x14
9+ ret x14
10 1:
11 // Special case: For the last input column (x1 == 8),
12 // which would be stored as the last row in the temp buffer,
13@@ -806,7 +806,7 @@ function \txfm\()16_1d_8x16_pass1_neon
14 mov v29.16b, v21.16b
15 mov v30.16b, v22.16b
16 mov v31.16b, v23.16b
17- br x14
18+ ret x14
19 endfunc
20
21 // Read a vertical 8x16 slice out of a 16x16 matrix, do a transform on it,
22@@ -834,7 +834,7 @@ function \txfm\()16_1d_8x16_pass2_neon
23 load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b
24 load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b
25
26- br x14
27+ ret x14
28 endfunc
29 .endm
30
31@@ -925,7 +925,7 @@ function ff_vp9_\txfm1\()_\txfm2\()_16x16_add_neon, ex
32 ldp d12, d13, [sp], 0x10
33 ldp d14, d15, [sp], 0x10
34 .endif
35- br x15
36+ ret x15
37 endfunc
38 .endm
39
40@@ -960,7 +960,7 @@ function idct16_1d_8x16_pass1_quarter_neon
41 .irp i, 24, 25, 26, 27
42 store \i, x0, x9
43 .endr
44- br x14
45+ ret x14
46 endfunc
47
48 function idct16_1d_8x16_pass2_quarter_neon
49@@ -978,7 +978,7 @@ function idct16_1d_8x16_pass2_quarter_neon
50 load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b
51 load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b
52
53- br x14
54+ ret x14
55 endfunc
56
57 function idct16_1d_8x16_pass1_half_neon
58@@ -1003,7 +1003,7 @@ function idct16_1d_8x16_pass1_half_neon
59 .irp i, 24, 25, 26, 27, 28, 29, 30, 31
60 store \i, x0, x9
61 .endr
62- br x14
63+ ret x14
64 endfunc
65
66 function idct16_1d_8x16_pass2_half_neon
67@@ -1021,7 +1021,7 @@ function idct16_1d_8x16_pass2_half_neon
68 load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b
69 load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b
70
71- br x14
72+ ret x14
73 endfunc
74
75 .macro idct16_partial size
76@@ -1038,7 +1038,7 @@ function idct16x16_\size\()_add_neon
77 .endr
78
79 add sp, sp, #512
80- br x15
81+ ret x15
82 endfunc
83 .endm
84
85@@ -1349,7 +1349,7 @@ function idct32_1d_8x32_pass1\suffix\()_neon
86 store_rev v25.8h, v17.8h
87 store_rev v24.8h, v16.8h
88 .purgem store_rev
89- br x14
90+ ret x14
91 endfunc
92
93 // This is mostly the same as 8x32_pass1, but without the transpose,
94@@ -1466,7 +1466,7 @@ function idct32_1d_8x32_pass2\suffix\()_neon
95 load_acc_store v24.8h, v25.8h, v26.8h, v27.8h, 1
96 load_acc_store v28.8h, v29.8h, v30.8h, v31.8h, 1
97 .purgem load_acc_store
98- br x14
99+ ret x14
100 endfunc
101 .endm
102
103@@ -1547,7 +1547,7 @@ function ff_vp9_idct_idct_32x32_add_neon, export=1
104 ldp d8, d9, [sp], 0x10
105 ldp d10, d11, [sp], 0x10
106
107- br x15
108+ ret x15
109 endfunc
110
111 .macro idct32_partial size
112@@ -1572,7 +1572,7 @@ function idct32x32_\size\()_add_neon
113 ldp d8, d9, [sp], 0x10
114 ldp d10, d11, [sp], 0x10
115
116- br x15
117+ ret x15
118 endfunc
119 .endm
120
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_16bpp_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_16bpp_neon_S
new file mode 100644
index 0000000..1174384
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_16bpp_neon_S
@@ -0,0 +1,174 @@
1Index: libavcodec/aarch64/vp9lpf_16bpp_neon.S
2--- libavcodec/aarch64/vp9lpf_16bpp_neon.S.orig
3+++ libavcodec/aarch64/vp9lpf_16bpp_neon.S
4@@ -69,7 +69,7 @@
5 mov x12, v4.d[1]
6 adds x11, x11, x12
7 b.ne 1f
8- br x10
9+ ret x10
10 1:
11
12 .if \wd >= 8
13@@ -205,7 +205,7 @@
14 b.eq 6f
15 .else
16 b.ne 1f
17- br x13
18+ ret x13
19 1:
20 .endif
21
22@@ -264,7 +264,7 @@
23 b.ne 1f
24 // If no pixels needed flat8in nor flat8out, jump to a
25 // writeout of the inner 4 pixels
26- br x14
27+ ret x14
28 1:
29
30 mov x11, v7.d[0]
31@@ -272,7 +272,7 @@
32 adds x11, x11, x12
33 b.ne 1f
34 // If no pixels need flat8out, jump to a writeout of the inner 6 pixels
35- br x15
36+ ret x15
37
38 1:
39 // flat8out
40@@ -446,7 +446,7 @@ function ff_\func\()_\bpp\()_neon, export=1
41 ldp d10, d11, [sp], 0x10
42 ldp d12, d13, [sp], 0x10
43 ldp d14, d15, [sp], 0x10
44- br x16
45+ ret x16
46 .else
47 b \func\()_16_neon
48 .endif
49@@ -486,7 +486,7 @@ function ff_\func\()_\suffix\()_\bpp\()_neon, export=1
50 ldp d12, d13, [sp], 0x10
51 ldp d14, d15, [sp], 0x10
52 .endif
53- br x16
54+ ret x16
55 endfunc
56 .endm
57
58@@ -520,7 +520,7 @@ function ff_vp9_loop_filter_\dir\()_\wd1\()\wd2\()_16_
59 lsl w3, w14, #\bpp - 8
60 lsl w4, w15, #\bpp - 8
61 bl vp9_loop_filter_\dir\()_\wd2\()_8_16_neon
62- br x16
63+ ret x16
64 endfunc
65 .endm
66
67@@ -553,7 +553,7 @@ function vp9_loop_filter_v_4_8_16_neon
68 st1 {v25.8h}, [x0], x1
69 sub x0, x0, x1, lsl #1
70
71- br x10
72+ ret x10
73 endfunc
74
75 bpp_frontends vp9_loop_filter_v_4_8
76@@ -601,7 +601,7 @@ function vp9_loop_filter_h_4_8_16_neon
77 sub x0, x0, x1, lsl #3
78 add x0, x0, #4
79
80- br x10
81+ ret x10
82 endfunc
83
84 bpp_frontends vp9_loop_filter_h_4_8
85@@ -632,7 +632,7 @@ function vp9_loop_filter_v_8_8_16_neon
86 sub x0, x0, x1, lsl #1
87 sub x0, x0, x1
88
89- br x10
90+ ret x10
91 6:
92 sub x9, x0, x1, lsl #1
93 st1 {v22.8h}, [x9], x1
94@@ -640,7 +640,7 @@ function vp9_loop_filter_v_8_8_16_neon
95 st1 {v23.8h}, [x9], x1
96 st1 {v25.8h}, [x0], x1
97 sub x0, x0, x1, lsl #1
98- br x10
99+ ret x10
100 endfunc
101
102 bpp_frontends vp9_loop_filter_v_8_8
103@@ -683,7 +683,7 @@ function vp9_loop_filter_h_8_8_16_neon
104 sub x0, x0, x1, lsl #3
105 add x0, x0, #8
106
107- br x10
108+ ret x10
109 6:
110 // If we didn't need to do the flat8in part, we use the same writeback
111 // as in loop_filter_h_4_8.
112@@ -700,7 +700,7 @@ function vp9_loop_filter_h_8_8_16_neon
113 st1 {v25.d}[1], [x0], x1
114 sub x0, x0, x1, lsl #3
115 add x0, x0, #4
116- br x10
117+ ret x10
118 endfunc
119
120 bpp_frontends vp9_loop_filter_h_8_8
121@@ -755,7 +755,7 @@ function vp9_loop_filter_v_16_8_16_neon
122 sub x0, x0, x1, lsl #3
123 add x0, x0, x1
124
125- br x10
126+ ret x10
127 8:
128 add x9, x9, x1, lsl #2
129 // If we didn't do the flat8out part, the output is left in the
130@@ -768,7 +768,7 @@ function vp9_loop_filter_v_16_8_16_neon
131 st1 {v26.8h}, [x0], x1
132 sub x0, x0, x1, lsl #1
133 sub x0, x0, x1
134- br x10
135+ ret x10
136 7:
137 sub x9, x0, x1, lsl #1
138 st1 {v22.8h}, [x9], x1
139@@ -776,7 +776,7 @@ function vp9_loop_filter_v_16_8_16_neon
140 st1 {v23.8h}, [x9], x1
141 st1 {v25.8h}, [x0], x1
142 sub x0, x0, x1, lsl #1
143- br x10
144+ ret x10
145 endfunc
146
147 bpp_frontends vp9_loop_filter_v_16_8, push=1
148@@ -833,7 +833,7 @@ function vp9_loop_filter_h_16_8_16_neon
149 st1 {v31.8h}, [x0], x1
150 sub x0, x0, x1, lsl #3
151
152- br x10
153+ ret x10
154 8:
155 // The same writeback as in loop_filter_h_8_8
156 sub x9, x0, #8
157@@ -850,7 +850,7 @@ function vp9_loop_filter_h_16_8_16_neon
158 st1 {v27.8h}, [x0], x1
159 sub x0, x0, x1, lsl #3
160 add x0, x0, #8
161- br x10
162+ ret x10
163 7:
164 // The same writeback as in loop_filter_h_4_8
165 sub x9, x0, #4
166@@ -866,7 +866,7 @@ function vp9_loop_filter_h_16_8_16_neon
167 st1 {v25.d}[1], [x0], x1
168 sub x0, x0, x1, lsl #3
169 add x0, x0, #4
170- br x10
171+ ret x10
172 endfunc
173
174 bpp_frontends vp9_loop_filter_h_16_8, push=1
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_neon_S b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_neon_S
new file mode 100644
index 0000000..5ca9c4a
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_aarch64_vp9lpf_neon_S
@@ -0,0 +1,220 @@
1Index: libavcodec/aarch64/vp9lpf_neon.S
2--- libavcodec/aarch64/vp9lpf_neon.S.orig
3+++ libavcodec/aarch64/vp9lpf_neon.S
4@@ -399,7 +399,7 @@
5 .endif
6 // If no pixels needed flat8in nor flat8out, jump to a
7 // writeout of the inner 4 pixels
8- br x14
9+ ret x14
10 1:
11
12 mov x5, v7.d[0]
13@@ -411,7 +411,7 @@
14 cbnz x5, 1f
15 .endif
16 // If no pixels need flat8out, jump to a writeout of the inner 6 pixels
17- br x15
18+ ret x15
19
20 1:
21 // flat8out
22@@ -532,32 +532,32 @@ function vp9_loop_filter_4
23 loop_filter 4, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31
24 ret
25 9:
26- br x10
27+ ret x10
28 endfunc
29
30 function vp9_loop_filter_4_16b_mix_44
31 loop_filter 4, .16b, 44, v16, v17, v18, v19, v28, v29, v30, v31
32 ret
33 9:
34- br x10
35+ ret x10
36 endfunc
37
38 function vp9_loop_filter_8
39 loop_filter 8, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31
40 ret
41 6:
42- br x13
43+ ret x13
44 9:
45- br x10
46+ ret x10
47 endfunc
48
49 function vp9_loop_filter_8_16b_mix
50 loop_filter 8, .16b, 88, v16, v17, v18, v19, v28, v29, v30, v31
51 ret
52 6:
53- br x13
54+ ret x13
55 9:
56- br x10
57+ ret x10
58 endfunc
59
60 function vp9_loop_filter_16
61@@ -568,7 +568,7 @@ function vp9_loop_filter_16
62 ldp d10, d11, [sp], 0x10
63 ldp d12, d13, [sp], 0x10
64 ldp d14, d15, [sp], 0x10
65- br x10
66+ ret x10
67 endfunc
68
69 function vp9_loop_filter_16_16b
70@@ -579,7 +579,7 @@ function vp9_loop_filter_16_16b
71 ldp d10, d11, [sp], 0x10
72 ldp d12, d13, [sp], 0x10
73 ldp d14, d15, [sp], 0x10
74- br x10
75+ ret x10
76 endfunc
77
78 .macro loop_filter_4
79@@ -648,7 +648,7 @@ function ff_vp9_loop_filter_v_4_8_neon, export=1
80 st1 {v23.8b}, [x9], x1
81 st1 {v25.8b}, [x0], x1
82
83- br x10
84+ ret x10
85 endfunc
86
87 function ff_vp9_loop_filter_v_44_16_neon, export=1
88@@ -672,7 +672,7 @@ function ff_vp9_loop_filter_v_44_16_neon, export=1
89 st1 {v23.16b}, [x9], x1
90 st1 {v25.16b}, [x0], x1
91
92- br x10
93+ ret x10
94 endfunc
95
96 function ff_vp9_loop_filter_h_4_8_neon, export=1
97@@ -714,7 +714,7 @@ function ff_vp9_loop_filter_h_4_8_neon, export=1
98 st1 {v25.s}[0], [x9], x1
99 st1 {v25.s}[1], [x0], x1
100
101- br x10
102+ ret x10
103 endfunc
104
105 function ff_vp9_loop_filter_h_44_16_neon, export=1
106@@ -766,7 +766,7 @@ function ff_vp9_loop_filter_h_44_16_neon, export=1
107 st1 {v25.s}[1], [x9], x1
108 st1 {v25.s}[3], [x0], x1
109
110- br x10
111+ ret x10
112 endfunc
113
114 function ff_vp9_loop_filter_v_8_8_neon, export=1
115@@ -793,14 +793,14 @@ function ff_vp9_loop_filter_v_8_8_neon, export=1
116 st1 {v23.8b}, [x9], x1
117 st1 {v26.8b}, [x0], x1
118
119- br x10
120+ ret x10
121 6:
122 sub x9, x0, x1, lsl #1
123 st1 {v22.8b}, [x9], x1
124 st1 {v24.8b}, [x0], x1
125 st1 {v23.8b}, [x9], x1
126 st1 {v25.8b}, [x0], x1
127- br x10
128+ ret x10
129 endfunc
130
131 .macro mix_v_16 mix
132@@ -828,14 +828,14 @@ function ff_vp9_loop_filter_v_\mix\()_16_neon, export=
133 st1 {v23.16b}, [x9], x1
134 st1 {v26.16b}, [x0], x1
135
136- br x10
137+ ret x10
138 6:
139 sub x9, x0, x1, lsl #1
140 st1 {v22.16b}, [x9], x1
141 st1 {v24.16b}, [x0], x1
142 st1 {v23.16b}, [x9], x1
143 st1 {v25.16b}, [x0], x1
144- br x10
145+ ret x10
146 endfunc
147 .endm
148
149@@ -876,7 +876,7 @@ function ff_vp9_loop_filter_h_8_8_neon, export=1
150 st1 {v23.8b}, [x9], x1
151 st1 {v27.8b}, [x0], x1
152
153- br x10
154+ ret x10
155 6:
156 // If we didn't need to do the flat8in part, we use the same writeback
157 // as in loop_filter_h_4_8.
158@@ -891,7 +891,7 @@ function ff_vp9_loop_filter_h_8_8_neon, export=1
159 st1 {v24.s}[1], [x0], x1
160 st1 {v25.s}[0], [x9], x1
161 st1 {v25.s}[1], [x0], x1
162- br x10
163+ ret x10
164 endfunc
165
166 .macro mix_h_16 mix
167@@ -942,7 +942,7 @@ function ff_vp9_loop_filter_h_\mix\()_16_neon, export=
168 st1 {v27.8b}, [x9], x1
169 st1 {v27.d}[1], [x0], x1
170
171- br x10
172+ ret x10
173 6:
174 add x9, x9, #2
175 add x0, x0, #2
176@@ -963,7 +963,7 @@ function ff_vp9_loop_filter_h_\mix\()_16_neon, export=
177 st1 {v24.s}[3], [x0], x1
178 st1 {v25.s}[1], [x9], x1
179 st1 {v25.s}[3], [x0], x1
180- br x10
181+ ret x10
182 endfunc
183 .endm
184
185@@ -1022,7 +1022,7 @@ function ff_vp9_loop_filter_v_16_8_neon, export=1
186 ldp d10, d11, [sp], 0x10
187 ldp d12, d13, [sp], 0x10
188 ldp d14, d15, [sp], 0x10
189- br x10
190+ ret x10
191 8:
192 add x9, x9, x1, lsl #2
193 // If we didn't do the flat8out part, the output is left in the
194@@ -1091,7 +1091,7 @@ function ff_vp9_loop_filter_v_16_16_neon, export=1
195 ldp d10, d11, [sp], 0x10
196 ldp d12, d13, [sp], 0x10
197 ldp d14, d15, [sp], 0x10
198- br x10
199+ ret x10
200 8:
201 add x9, x9, x1, lsl #2
202 st1 {v21.16b}, [x9], x1
203@@ -1168,7 +1168,7 @@ function ff_vp9_loop_filter_h_16_8_neon, export=1
204 ldp d10, d11, [sp], 0x10
205 ldp d12, d13, [sp], 0x10
206 ldp d14, d15, [sp], 0x10
207- br x10
208+ ret x10
209 8:
210 // The same writeback as in loop_filter_h_8_8
211 sub x9, x0, #4
212@@ -1287,7 +1287,7 @@ function ff_vp9_loop_filter_h_16_16_neon, export=1
213 ldp d10, d11, [sp], 0x10
214 ldp d12, d13, [sp], 0x10
215 ldp d14, d15, [sp], 0x10
216- br x10
217+ ret x10
218 8:
219 sub x9, x0, #4
220 add x0, x9, x1, lsl #3
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_libaomenc_c b/graphics/ffmpeg/patches/patch-libavcodec_libaomenc_c
new file mode 100644
index 0000000..254b5ee
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_libaomenc_c
@@ -0,0 +1,218 @@
1- lavc/aomenc: Force default qmax of 0 if crf was set to 0
2- avcodec/libaomenc: Avoid copying data, allow user-supplied buffers
3- lavc/libaomenc: Show encoder config as a warning in case of failed initialization
4- avcodec/libaomenc: use ctx->usage to get default cfg
5- avcodec/libaomenc: remove the redundant initialization
6- avcodec/libaomenc: Add unmet target level warning
7- avcodec/libaomenc: Expose the allintra usage mode
8- avcodec/libaomenc: Get number of operating points
9
10Index: libavcodec/libaomenc.c
11--- libavcodec/libaomenc.c.orig
12+++ libavcodec/libaomenc.c
13@@ -36,6 +36,7 @@
14
15 #include "av1.h"
16 #include "avcodec.h"
17+#include "encode.h"
18 #include "internal.h"
19 #include "packet_internal.h"
20 #include "profiles.h"
21@@ -194,6 +195,15 @@ static const char *const ctlidstr[] = {
22 [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
23 [AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
24 #endif
25+#ifdef AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS
26+ [AV1E_GET_NUM_OPERATING_POINTS] = "AV1E_GET_NUM_OPERATING_POINTS",
27+#endif
28+#ifdef AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX
29+ [AV1E_GET_SEQ_LEVEL_IDX] = "AV1E_GET_SEQ_LEVEL_IDX",
30+#endif
31+#ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
32+ [AV1E_GET_TARGET_SEQ_LEVEL_IDX] = "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
33+#endif
34 };
35
36 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
37@@ -208,10 +218,10 @@ static av_cold void log_encoder_error(AVCodecContext *
38 }
39
40 static av_cold void dump_enc_cfg(AVCodecContext *avctx,
41- const struct aom_codec_enc_cfg *cfg)
42+ const struct aom_codec_enc_cfg *cfg,
43+ int level)
44 {
45 int width = -30;
46- int level = AV_LOG_DEBUG;
47
48 av_log(avctx, level, "aom_codec_enc_cfg\n");
49 av_log(avctx, level, "generic settings\n"
50@@ -319,10 +329,73 @@ static av_cold int codecctl_int(AVCodecContext *avctx,
51 return 0;
52 }
53
54+#if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
55+ defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
56+ defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
57+static av_cold int codecctl_intp(AVCodecContext *avctx,
58+#ifdef UENUM1BYTE
59+ aome_enc_control_id id,
60+#else
61+ enum aome_enc_control_id id,
62+#endif
63+ int* ptr)
64+{
65+ AOMContext *ctx = avctx->priv_data;
66+ char buf[80];
67+ int width = -30;
68+ int res;
69+
70+ snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
71+ av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, *ptr);
72+
73+ res = aom_codec_control(&ctx->encoder, id, ptr);
74+ if (res != AOM_CODEC_OK) {
75+ snprintf(buf, sizeof(buf), "Failed to set %s codec control",
76+ ctlidstr[id]);
77+ log_encoder_error(avctx, buf);
78+ return AVERROR(EINVAL);
79+ }
80+
81+ return 0;
82+}
83+#endif
84+
85 static av_cold int aom_free(AVCodecContext *avctx)
86 {
87 AOMContext *ctx = avctx->priv_data;
88
89+#if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
90+ defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
91+ defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
92+ if (!(avctx->flags & AV_CODEC_FLAG_PASS1)) {
93+ int num_operating_points;
94+ int levels[32];
95+ int target_levels[32];
96+
97+ if (!codecctl_intp(avctx, AV1E_GET_NUM_OPERATING_POINTS,
98+ &num_operating_points) &&
99+ !codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
100+ !codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
101+ target_levels)) {
102+ for (int i = 0; i < num_operating_points; i++) {
103+ if (levels[i] > target_levels[i]) {
104+ // Warn when the target level was not met
105+ av_log(avctx, AV_LOG_WARNING,
106+ "Could not encode to target level %d.%d for "
107+ "operating point %d. The output level is %d.%d.\n",
108+ 2 + (target_levels[i] >> 2), target_levels[i] & 3,
109+ i, 2 + (levels[i] >> 2), levels[i] & 3);
110+ } else if (target_levels[i] < 31) {
111+ // Log the encoded level if a target level was given
112+ av_log(avctx, AV_LOG_INFO,
113+ "Output level for operating point %d is %d.%d.\n",
114+ i, 2 + (levels[i] >> 2), levels[i] & 3);
115+ }
116+ }
117+ }
118+ }
119+#endif
120+
121 aom_codec_destroy(&ctx->encoder);
122 av_freep(&ctx->twopass_stats.buf);
123 av_freep(&avctx->stats_out);
124@@ -596,7 +669,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
125 av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
126 av_log(avctx, AV_LOG_VERBOSE, "%s\n", aom_codec_build_config());
127
128- if ((res = aom_codec_enc_config_default(iface, &enccfg, 0)) != AOM_CODEC_OK) {
129+ if ((res = aom_codec_enc_config_default(iface, &enccfg, ctx->usage)) != AOM_CODEC_OK) {
130 av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
131 aom_codec_err_to_string(res));
132 return AVERROR(EINVAL);
133@@ -611,7 +684,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
134 return AVERROR(EINVAL);
135 }
136
137- dump_enc_cfg(avctx, &enccfg);
138+ dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG);
139
140 enccfg.g_w = avctx->width;
141 enccfg.g_h = avctx->height;
142@@ -620,8 +693,6 @@ static av_cold int aom_init(AVCodecContext *avctx,
143 enccfg.g_threads =
144 FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64);
145
146- enccfg.g_usage = ctx->usage;
147-
148 if (ctx->lag_in_frames >= 0)
149 enccfg.g_lag_in_frames = ctx->lag_in_frames;
150
151@@ -654,8 +725,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
152
153 if (avctx->qmin >= 0)
154 enccfg.rc_min_quantizer = avctx->qmin;
155- if (avctx->qmax >= 0)
156+ if (avctx->qmax >= 0) {
157 enccfg.rc_max_quantizer = avctx->qmax;
158+ } else if (!ctx->crf) {
159+ enccfg.rc_max_quantizer = 0;
160+ }
161
162 if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
163 if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
164@@ -742,13 +816,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
165 if (res < 0)
166 return res;
167
168- dump_enc_cfg(avctx, &enccfg);
169 /* Construct Encoder Context */
170 res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
171 if (res != AOM_CODEC_OK) {
172+ dump_enc_cfg(avctx, &enccfg, AV_LOG_WARNING);
173 log_encoder_error(avctx, "Failed to initialize encoder");
174 return AVERROR(EINVAL);
175 }
176+ dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG);
177
178 // codec control failures are currently treated only as warnings
179 av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
180@@ -943,7 +1018,6 @@ static inline void cx_pktcpy(AOMContext *ctx,
181 dst->sz = src->data.frame.sz;
182 dst->buf = src->data.frame.buf;
183 #ifdef AOM_FRAME_IS_INTRAONLY
184- dst->have_sse = 0;
185 dst->frame_number = ++ctx->frame_number;
186 dst->have_sse = ctx->have_sse;
187 if (ctx->have_sse) {
188@@ -967,7 +1041,7 @@ static int storeframe(AVCodecContext *avctx, struct Fr
189 {
190 AOMContext *ctx = avctx->priv_data;
191 int av_unused pict_type;
192- int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0);
193+ int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
194 if (ret < 0) {
195 av_log(avctx, AV_LOG_ERROR,
196 "Error getting output packet of size %"SIZE_SPECIFIER".\n", cx_frame->sz);
197@@ -1282,6 +1356,7 @@ static const AVOption options[] = {
198 { "usage", "Quality and compression efficiency vs speed trade-off", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "usage"},
199 { "good", "Good quality", 0, AV_OPT_TYPE_CONST, {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, "usage"},
200 { "realtime", "Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 /* AOM_USAGE_REALTIME */}, 0, 0, VE, "usage"},
201+ { "allintra", "All Intra encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 2 /* AOM_USAGE_ALL_INTRA */}, 0, 0, VE, "usage"},
202 { "tune", "The metric that the encoder tunes for. Automatically chosen by the encoder by default", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_TUNE_SSIM, VE, "tune"},
203 { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
204 { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
205@@ -1341,11 +1416,12 @@ AVCodec ff_libaom_av1_encoder = {
206 .long_name = NULL_IF_CONFIG_SMALL("libaom AV1"),
207 .type = AVMEDIA_TYPE_VIDEO,
208 .id = AV_CODEC_ID_AV1,
209+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
210+ AV_CODEC_CAP_OTHER_THREADS,
211 .priv_data_size = sizeof(AOMContext),
212 .init = av1_init,
213 .encode2 = aom_encode,
214 .close = aom_free,
215- .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
216 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
217 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
218 .priv_class = &class_aom,
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c b/graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c
new file mode 100644
index 0000000..9170e88
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c
@@ -0,0 +1,389 @@
1- avcodec/libsvtav1: Fix duplicate definition of caps_internal
2- avcodec/libsvtav1: make coded GOP type configurable
3- avcodec/libsvtav1: Fix value range for rc mode
4- avcodec/libsvtav1: properly enforce CQP mode when set in wrapper
5- avcodec/libsvtav1: add a svtav1-params option to pass a list of key=value parameters
6- avcodec/libsvtav1: update some options and defaults
7- avcodec/libsvtav1: deprecate some options
8- avcodec/libsvtav1: fine tune qp mode settings
9- avcodec/libsvtav1: pass color description info
10- avcodec/libsvtav1: give svtav1-params priority over avctx values
11- avcodec/libsvtav1: pass pict_type to library
12- avcodec/libsvtav1: add support for setting chroma sample location
13- avcodec/libsvtav1: update avctx bit rate according to RC mode
14- avcodec/libsvtav1: signal CPB properties through side data
15- avcodec/libsvtav1: properly initialize the flush EbBufferHeaderType struct
16- avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
17- avcodec/libsvtav1: replace vbv_bufsize with maximum_buffer_size_ms
18- avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set
19- avcodec/libsvtav1: don't force a default value for deprecated options
20
21Index: libavcodec/libsvtav1.c
22--- libavcodec/libsvtav1.c.orig
23+++ libavcodec/libsvtav1.c
24@@ -60,17 +60,20 @@ typedef struct SvtContext {
25 EOS_STATUS eos_flag;
26
27 // User options.
28+ AVDictionary *svtav1_opts;
29+#if FF_API_SVTAV1_OPTS
30 int hierarchical_level;
31 int la_depth;
32- int enc_mode;
33- int rc_mode;
34 int scd;
35- int qp;
36
37 int tier;
38
39 int tile_columns;
40 int tile_rows;
41+#endif
42+ int enc_mode;
43+ int crf;
44+ int qp;
45 } SvtContext;
46
47 static const struct {
48@@ -120,16 +123,12 @@ static int svt_print_error(void *log_ctx, EbErrorType
49
50 static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
51 {
52- const int pack_mode_10bit =
53- (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
54- const size_t luma_size_8bit =
55- config->source_width * config->source_height * (1 << pack_mode_10bit);
56- const size_t luma_size_10bit =
57- (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
58+ const size_t luma_size = config->source_width * config->source_height *
59+ (config->encoder_bit_depth > 8 ? 2 : 1);
60
61 EbSvtIOFormat *in_data;
62
63- svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
64+ svt_enc->raw_size = luma_size * 3 / 2;
65
66 // allocate buffer for in and out
67 svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf));
68@@ -151,11 +150,132 @@ static int config_enc_params(EbSvtAv1EncConfiguration
69 {
70 SvtContext *svt_enc = avctx->priv_data;
71 const AVPixFmtDescriptor *desc;
72+ AVDictionaryEntry *en = NULL;
73
74+ // Update param from options
75+#if FF_API_SVTAV1_OPTS
76+ if (svt_enc->hierarchical_level >= 0)
77+ param->hierarchical_levels = svt_enc->hierarchical_level;
78+ if (svt_enc->tier >= 0)
79+ param->tier = svt_enc->tier;
80+ if (svt_enc->scd >= 0)
81+ param->scene_change_detection = svt_enc->scd;
82+ if (svt_enc->tile_columns >= 0)
83+ param->tile_columns = svt_enc->tile_columns;
84+ if (svt_enc->tile_rows >= 0)
85+ param->tile_rows = svt_enc->tile_rows;
86+
87+ if (svt_enc->la_depth >= 0)
88+ param->look_ahead_distance = svt_enc->la_depth;
89+#endif
90+
91+ if (svt_enc->enc_mode >= 0)
92+ param->enc_mode = svt_enc->enc_mode;
93+
94+ if (avctx->bit_rate) {
95+ param->target_bit_rate = avctx->bit_rate;
96+ if (avctx->rc_max_rate != avctx->bit_rate)
97+ param->rate_control_mode = 1;
98+ else
99+ param->rate_control_mode = 2;
100+
101+ param->max_qp_allowed = avctx->qmax;
102+ param->min_qp_allowed = avctx->qmin;
103+ }
104+ param->max_bit_rate = avctx->rc_max_rate;
105+ if (avctx->bit_rate && avctx->rc_buffer_size)
106+ param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
107+
108+ if (svt_enc->crf > 0) {
109+ param->qp = svt_enc->crf;
110+ param->rate_control_mode = 0;
111+ } else if (svt_enc->qp > 0) {
112+ param->qp = svt_enc->qp;
113+ param->rate_control_mode = 0;
114+ param->enable_adaptive_quantization = 0;
115+ }
116+
117+ desc = av_pix_fmt_desc_get(avctx->pix_fmt);
118+ param->color_primaries = avctx->color_primaries;
119+ param->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ?
120+ AVCOL_SPC_RGB : avctx->colorspace;
121+ param->transfer_characteristics = avctx->color_trc;
122+
123+ if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED)
124+ param->color_range = avctx->color_range == AVCOL_RANGE_JPEG;
125+ else
126+ param->color_range = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
127+
128+#if SVT_AV1_CHECK_VERSION(1, 0, 0)
129+ if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) {
130+ const char *name =
131+ av_chroma_location_name(avctx->chroma_sample_location);
132+
133+ switch (avctx->chroma_sample_location) {
134+ case AVCHROMA_LOC_LEFT:
135+ param->chroma_sample_position = EB_CSP_VERTICAL;
136+ break;
137+ case AVCHROMA_LOC_TOPLEFT:
138+ param->chroma_sample_position = EB_CSP_COLOCATED;
139+ break;
140+ default:
141+ if (!name)
142+ break;
143+
144+ av_log(avctx, AV_LOG_WARNING,
145+ "Specified chroma sample location %s is unsupported "
146+ "on the AV1 bit stream level. Usage of a container that "
147+ "allows passing this information - such as Matroska - "
148+ "is recommended.\n",
149+ name);
150+ break;
151+ }
152+ }
153+#endif
154+
155+ if (avctx->profile != FF_PROFILE_UNKNOWN)
156+ param->profile = avctx->profile;
157+
158+ if (avctx->level != FF_LEVEL_UNKNOWN)
159+ param->level = avctx->level;
160+
161+ if (avctx->gop_size > 0)
162+ param->intra_period_length = avctx->gop_size - 1;
163+
164+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
165+ param->frame_rate_numerator = avctx->framerate.num;
166+ param->frame_rate_denominator = avctx->framerate.den;
167+ } else {
168+ param->frame_rate_numerator = avctx->time_base.den;
169+ param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
170+ }
171+
172+ /* 2 = IDR, closed GOP, 1 = CRA, open GOP */
173+ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
174+
175+#if SVT_AV1_CHECK_VERSION(0, 9, 1)
176+ while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
177+ EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value);
178+ if (ret != EB_ErrorNone) {
179+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
180+ av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value);
181+ if (avctx->err_recognition & AV_EF_EXPLODE)
182+ return AVERROR(EINVAL);
183+ }
184+ }
185+#else
186+ if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
187+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
188+ av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 "
189+ "headers >= 0.9.1.\n");
190+ if (avctx->err_recognition & AV_EF_EXPLODE)
191+ return AVERROR(ENOSYS);
192+ }
193+#endif
194+
195 param->source_width = avctx->width;
196 param->source_height = avctx->height;
197
198- desc = av_pix_fmt_desc_get(avctx->pix_fmt);
199 param->encoder_bit_depth = desc->comp[0].depth;
200
201 if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1)
202@@ -169,12 +289,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration
203 return AVERROR(EINVAL);
204 }
205
206- if (avctx->profile != FF_PROFILE_UNKNOWN)
207- param->profile = avctx->profile;
208-
209- if (avctx->level != FF_LEVEL_UNKNOWN)
210- param->level = avctx->level;
211-
212 if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10)
213 && param->profile != FF_PROFILE_AV1_PROFESSIONAL ) {
214 av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
215@@ -184,40 +298,21 @@ static int config_enc_params(EbSvtAv1EncConfiguration
216 param->profile = FF_PROFILE_AV1_HIGH;
217 }
218
219- // Update param from options
220- param->hierarchical_levels = svt_enc->hierarchical_level;
221- param->enc_mode = svt_enc->enc_mode;
222- param->tier = svt_enc->tier;
223- param->rate_control_mode = svt_enc->rc_mode;
224- param->scene_change_detection = svt_enc->scd;
225- param->qp = svt_enc->qp;
226+ avctx->bit_rate = param->rate_control_mode > 0 ?
227+ param->target_bit_rate : 0;
228+ avctx->rc_max_rate = param->max_bit_rate;
229+ avctx->rc_buffer_size = param->maximum_buffer_size_ms * avctx->bit_rate / 1000LL;
230
231- param->target_bit_rate = avctx->bit_rate;
232+ if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
233+ AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
234+ if (!cpb_props)
235+ return AVERROR(ENOMEM);
236
237- if (avctx->gop_size > 0)
238- param->intra_period_length = avctx->gop_size - 1;
239-
240- if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
241- param->frame_rate_numerator = avctx->framerate.num;
242- param->frame_rate_denominator = avctx->framerate.den;
243- } else {
244- param->frame_rate_numerator = avctx->time_base.den;
245- param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
246+ cpb_props->buffer_size = avctx->rc_buffer_size;
247+ cpb_props->max_bitrate = avctx->rc_max_rate;
248+ cpb_props->avg_bitrate = avctx->bit_rate;
249 }
250
251- if (param->rate_control_mode) {
252- param->max_qp_allowed = avctx->qmax;
253- param->min_qp_allowed = avctx->qmin;
254- }
255-
256- param->intra_refresh_type = 2; /* Real keyframes only */
257-
258- if (svt_enc->la_depth >= 0)
259- param->look_ahead_distance = svt_enc->la_depth;
260-
261- param->tile_columns = svt_enc->tile_columns;
262- param->tile_rows = svt_enc->tile_rows;
263-
264 return 0;
265 }
266
267@@ -330,11 +425,8 @@ static int eb_send_frame(AVCodecContext *avctx, const
268 if (svt_enc->eos_flag == EOS_SENT)
269 return 0;
270
271- headerPtrLast.n_alloc_len = 0;
272- headerPtrLast.n_filled_len = 0;
273- headerPtrLast.n_tick_count = 0;
274- headerPtrLast.p_app_private = NULL;
275- headerPtrLast.p_buffer = NULL;
276+ memset(&headerPtrLast, 0, sizeof(headerPtrLast));
277+ headerPtrLast.pic_type = EB_AV1_INVALID_PICTURE;
278 headerPtrLast.flags = EB_BUFFERFLAG_EOS;
279
280 svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);
281@@ -350,6 +442,16 @@ static int eb_send_frame(AVCodecContext *avctx, const
282 headerPtr->p_app_private = NULL;
283 headerPtr->pts = frame->pts;
284
285+ switch (frame->pict_type) {
286+ case AV_PICTURE_TYPE_I:
287+ headerPtr->pic_type = EB_AV1_KEY_PICTURE;
288+ break;
289+ default:
290+ // Actually means auto, or default.
291+ headerPtr->pic_type = EB_AV1_INVALID_PICTURE;
292+ break;
293+ }
294+
295 svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr);
296
297 return 0;
298@@ -472,21 +574,22 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
299 #define OFFSET(x) offsetof(SvtContext, x)
300 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
301 static const AVOption options[] = {
302- { "hielevel", "Hierarchical prediction levels setting", OFFSET(hierarchical_level),
303- AV_OPT_TYPE_INT, { .i64 = 4 }, 3, 4, VE , "hielevel"},
304+#if FF_API_SVTAV1_OPTS
305+ { "hielevel", "Hierarchical prediction levels setting (Deprecated, use svtav1-params)", OFFSET(hierarchical_level),
306+ AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 4, VE | AV_OPT_FLAG_DEPRECATED , "hielevel"},
307 { "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "hielevel" },
308 { "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, INT_MIN, INT_MAX, VE, "hielevel" },
309
310- { "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
311- AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
312+ { "la_depth", "Look ahead distance [0, 120] (Deprecated, use svtav1-params)", OFFSET(la_depth),
313+ AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE | AV_OPT_FLAG_DEPRECATED },
314
315- { "preset", "Encoding preset [0, 8]",
316- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, MAX_ENC_PRESET, VE },
317-
318- { "tier", "Set operating point tier", OFFSET(tier),
319- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" },
320+ { "tier", "Set operating point tier (Deprecated, use svtav1-params)", OFFSET(tier),
321+ AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE | AV_OPT_FLAG_DEPRECATED, "tier" },
322 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" },
323 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" },
324+#endif
325+ { "preset", "Encoding preset",
326+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, MAX_ENC_PRESET, VE },
327
328 FF_AV1_PROFILE_OPTS
329
330@@ -518,21 +621,20 @@ static const AVOption options[] = {
331 { LEVEL("7.3", 73) },
332 #undef LEVEL
333
334- { "rc", "Bit rate control mode", OFFSET(rc_mode),
335- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"},
336- { "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" },
337- { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" },
338- { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" },
339+ { "crf", "Constant Rate Factor value", OFFSET(crf),
340+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
341+ { "qp", "Initial Quantizer level value", OFFSET(qp),
342+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
343+#if FF_API_SVTAV1_OPTS
344+ { "sc_detection", "Scene change detection (Deprecated, use svtav1-params)", OFFSET(scd),
345+ AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE | AV_OPT_FLAG_DEPRECATED },
346
347- { "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp),
348- AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
349+ { "tile_columns", "Log2 of number of tile columns to use (Deprecated, use svtav1-params)", OFFSET(tile_columns), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 4, VE | AV_OPT_FLAG_DEPRECATED },
350+ { "tile_rows", "Log2 of number of tile rows to use (Deprecated, use svtav1-params)", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 6, VE | AV_OPT_FLAG_DEPRECATED },
351+#endif
352
353- { "sc_detection", "Scene change detection", OFFSET(scd),
354- AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
355+ { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
356
357- { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
358- { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
359-
360 {NULL},
361 };
362
363@@ -544,9 +646,10 @@ static const AVClass class = {
364 };
365
366 static const AVCodecDefault eb_enc_defaults[] = {
367- { "b", "7M" },
368+ { "b", "0" },
369+ { "flags", "+cgop" },
370 { "g", "-1" },
371- { "qmin", "0" },
372+ { "qmin", "1" },
373 { "qmax", "63" },
374 { NULL },
375 };
376@@ -561,12 +664,11 @@ AVCodec ff_libsvtav1_encoder = {
377 .receive_packet = eb_receive_packet,
378 .close = eb_enc_close,
379 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
380- .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
381+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP,
382 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
383 AV_PIX_FMT_YUV420P10,
384 AV_PIX_FMT_NONE },
385 .priv_class = &class,
386 .defaults = eb_enc_defaults,
387- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
388 .wrapper_name = "libsvtav1",
389 };
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_version_h b/graphics/ffmpeg/patches/patch-libavcodec_version_h
new file mode 100644
index 0000000..929731d
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_version_h
@@ -0,0 +1,14 @@
1avcodec/libsvtav1: deprecate some options
2
3Index: libavcodec/version.h
4--- libavcodec/version.h.orig
5+++ libavcodec/version.h
6@@ -168,5 +168,8 @@
7 #ifndef FF_API_INIT_PACKET
8 #define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
9 #endif
10+#ifndef FF_API_SVTAV1_OPTS
11+#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
12+#endif
13
14 #endif /* AVCODEC_VERSION_H */
diff --git a/graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm b/graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm
new file mode 100644
index 0000000..c1d16cd
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm
@@ -0,0 +1,128 @@
1- place a table in rodata
2- use _CET_ENDBR in functions header
3
4Index: libavcodec/x86/fft.asm
5--- libavcodec/x86/fft.asm.orig
6+++ libavcodec/x86/fft.asm
7@@ -325,6 +325,7 @@ INIT_YMM avx
8 %if HAVE_AVX_EXTERNAL
9 align 16
10 fft8_avx:
11+ _CET_ENDBR
12 mova m0, Z(0)
13 mova m1, Z(1)
14 T8_AVX m0, m1, m2, m3, m4
15@@ -335,6 +336,7 @@ fft8_avx:
16
17 align 16
18 fft16_avx:
19+ _CET_ENDBR
20 mova m2, Z(2)
21 mova m3, Z(3)
22 T4_SSE m2, m3, m7
23@@ -372,6 +374,7 @@ fft16_avx:
24
25 align 16
26 fft32_avx:
27+ _CET_ENDBR
28 call fft16_avx
29
30 mova m0, Z(4)
31@@ -396,6 +399,7 @@ fft32_avx:
32 ret
33
34 fft32_interleave_avx:
35+ _CET_ENDBR
36 call fft32_avx
37 mov r2d, 32
38 .deint_loop:
39@@ -419,6 +423,7 @@ INIT_XMM sse
40 align 16
41 fft4_avx:
42 fft4_sse:
43+ _CET_ENDBR
44 mova m0, Z(0)
45 mova m1, Z(1)
46 T4_SSE m0, m1, m2
47@@ -428,6 +433,7 @@ fft4_sse:
48
49 align 16
50 fft8_sse:
51+ _CET_ENDBR
52 mova m0, Z(0)
53 mova m1, Z(1)
54 T4_SSE m0, m1, m2
55@@ -442,6 +448,7 @@ fft8_sse:
56
57 align 16
58 fft16_sse:
59+ _CET_ENDBR
60 mova m0, Z(0)
61 mova m1, Z(1)
62 T4_SSE m0, m1, m2
63@@ -465,6 +472,7 @@ fft16_sse:
64 %macro FFT48_3DNOW 0
65 align 16
66 fft4 %+ SUFFIX:
67+ _CET_ENDBR
68 T2_3DNOW m0, m1, Z(0), Z(1)
69 mova m2, Z(2)
70 mova m3, Z(3)
71@@ -479,6 +487,7 @@ fft4 %+ SUFFIX:
72
73 align 16
74 fft8 %+ SUFFIX:
75+ _CET_ENDBR
76 T2_3DNOW m0, m1, Z(0), Z(1)
77 mova m2, Z(2)
78 mova m3, Z(3)
79@@ -532,6 +541,7 @@ FFT48_3DNOW
80 %macro DECL_PASS 2+ ; name, payload
81 align 16
82 %1:
83+ _CET_ENDBR
84 DEFINE_ARGS zc, w, n, o1, o3
85 lea o3q, [nq*3]
86 lea o1q, [nq*8]
87@@ -548,10 +558,6 @@ DEFINE_ARGS zc, w, n, o1, o3
88 %macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
89 lea r2, [dispatch_tab%1]
90 mov r2, [r2 + (%2q-2)*gprsize]
91-%ifdef PIC
92- lea r3, [$$]
93- add r2, r3
94-%endif
95 call r2
96 %endmacro ; FFT_DISPATCH
97
98@@ -731,11 +737,7 @@ DECL_PASS pass_interleave_3dnow, PASS_BIG 0
99 %define pass_interleave_3dnowext pass_interleave_3dnow
100 %endif
101
102-%ifdef PIC
103-%define SECTION_REL - $$
104-%else
105 %define SECTION_REL
106-%endif
107
108 %macro DECL_FFT 1-2 ; nbits, suffix
109 %ifidn %0, 1
110@@ -759,6 +761,7 @@ DECL_PASS pass_interleave_3dnow, PASS_BIG 0
111
112 align 16
113 fft %+ n %+ fullsuffix:
114+ _CET_ENDBR
115 call fft %+ n2 %+ SUFFIX
116 add r0, n*4 - (n&(-2<<%1))
117 call fft %+ n4 %+ SUFFIX
118@@ -773,8 +776,10 @@ fft %+ n %+ fullsuffix:
119 %endrep
120 %undef n
121
122+[SECTION .data.rel.ro write]
123 align 8
124 dispatch_tab %+ fullsuffix: pointer list_of_fft
125+__?SECT?__
126 %endmacro ; DECL_FFT
127
128 %if HAVE_AVX_EXTERNAL
diff --git a/graphics/ffmpeg/patches/patch-libavformat_rtpproto_c b/graphics/ffmpeg/patches/patch-libavformat_rtpproto_c
new file mode 100644
index 0000000..6c50152
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavformat_rtpproto_c
@@ -0,0 +1,14 @@
1avformat/rtpproto: set ttl upper bound to 255
2
3Index: libavformat/rtpproto.c
4--- libavformat/rtpproto.c.orig
5+++ libavformat/rtpproto.c
6@@ -67,7 +67,7 @@ typedef struct RTPContext {
7 #define D AV_OPT_FLAG_DECODING_PARAM
8 #define E AV_OPT_FLAG_ENCODING_PARAM
9 static const AVOption options[] = {
10- { "ttl", "Time to live (in milliseconds, multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
11+ { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E },
12 { "buffer_size", "Send/Receive buffer size (in bytes)", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
13 { "rtcp_port", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
14 { "local_rtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
diff --git a/graphics/ffmpeg/patches/patch-libavformat_udp_c b/graphics/ffmpeg/patches/patch-libavformat_udp_c
new file mode 100644
index 0000000..ff1e234
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavformat_udp_c
@@ -0,0 +1,82 @@
1- avformat/udp: set ttl upper bound to 255
2- avformat/udp: properly check for valid ttl in url
3- avformat/udp: use one setsockopt for ipv4/ipv6
4- avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility
5- avformat/udp: remove IPPROTO_IPV6 macro
6
7Index: libavformat/udp.c
8--- libavformat/udp.c.orig
9+++ libavformat/udp.c
10@@ -134,7 +134,7 @@ static const AVOption options[] = {
11 { "reuse", "explicitly allow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, D|E },
12 { "reuse_socket", "explicitly allow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E },
13 { "broadcast", "explicitly allow or disallow broadcast destination", OFFSET(is_broadcast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
14- { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, INT_MAX, E },
15+ { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 255, E },
16 { "connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
17 { "fifo_size", "set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, D },
18 { "overrun_nonfatal", "survive in case of UDP receiving circular buffer overrun", OFFSET(overrun_nonfatal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D },
19@@ -161,22 +161,40 @@ static const AVClass udplite_context_class = {
20 static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
21 struct sockaddr *addr)
22 {
23+ int protocol, cmd;
24+
25+ /* There is some confusion in the world whether IP_MULTICAST_TTL
26+ * takes a byte or an int as an argument.
27+ * BSD seems to indicate byte so we are going with that and use
28+ * int and fall back to byte to be safe */
29+ switch (addr->sa_family) {
30 #ifdef IP_MULTICAST_TTL
31- if (addr->sa_family == AF_INET) {
32- if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) {
33- ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
34- return ff_neterrno();
35- }
36- }
37+ case AF_INET:
38+ protocol = IPPROTO_IP;
39+ cmd = IP_MULTICAST_TTL;
40+ break;
41 #endif
42-#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
43- if (addr->sa_family == AF_INET6) {
44- if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) {
45- ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)");
46+#ifdef IPV6_MULTICAST_HOPS
47+ case AF_INET6:
48+ protocol = IPPROTO_IPV6;
49+ cmd = IPV6_MULTICAST_HOPS;
50+ break;
51+#endif
52+ default:
53+ return 0;
54+ }
55+
56+ if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) {
57+ /* BSD compatibility */
58+ unsigned char ttl = (unsigned char) mcastTTL;
59+
60+ ff_log_net_error(NULL, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
61+ if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) {
62+ ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
63 return ff_neterrno();
64 }
65 }
66-#endif
67+
68 return 0;
69 }
70
71@@ -673,6 +691,11 @@ static int udp_open(URLContext *h, const char *uri, in
72 }
73 if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
74 s->ttl = strtol(buf, NULL, 10);
75+ if (s->ttl < 0 || s->ttl > 255) {
76+ av_log(h, AV_LOG_ERROR, "ttl(%d) should be in range [0,255]\n", s->ttl);
77+ ret = AVERROR(EINVAL);
78+ goto fail;
79+ }
80 }
81 if (av_find_info_tag(buf, sizeof(buf), "udplite_coverage", p)) {
82 s->udplite_coverage = strtol(buf, NULL, 10);
diff --git a/graphics/ffmpeg/patches/patch-libavformat_utils_c b/graphics/ffmpeg/patches/patch-libavformat_utils_c
new file mode 100644
index 0000000..fa0c918
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavformat_utils_c
@@ -0,0 +1,24 @@
1llvm 16 optimizations lead to a segfault when seeking in opus files because
2checks that could leave pos_max uninitialized are optimized away, leading
3to out-of-bounds reads from the guard pages.
4
5av_uninit() is complete batshittery:
6
7https://marc.info/?l=openbsd-ports&m=170284868209618&w=2
8
9Turns out the same commit has landed upstream:
10
11https://github.com/FFmpeg/FFmpeg/commit/ab792634197e364ca1bb194f9abe36836e42f12d
12
13Index: libavformat/utils.c
14--- libavformat/utils.c.orig
15+++ libavformat/utils.c
16@@ -2146,7 +2146,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int strea
17 int64_t target_ts, int flags)
18 {
19 const AVInputFormat *avif = s->iformat;
20- int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
21+ int64_t pos_min = 0, pos_max = 0, pos, pos_limit;
22 int64_t ts_min, ts_max, ts;
23 int index;
24 int64_t ret;
diff --git a/graphics/ffmpeg/patches/patch-libavutil_aarch64_asm_S b/graphics/ffmpeg/patches/patch-libavutil_aarch64_asm_S
new file mode 100644
index 0000000..bee9f51
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavutil_aarch64_asm_S
@@ -0,0 +1,137 @@
1Index: libavutil/aarch64/asm.S
2--- libavutil/aarch64/asm.S.orig
3+++ libavutil/aarch64/asm.S
4@@ -36,6 +36,125 @@
5 # define __has_feature(x) 0
6 #endif
7
8+
9+/* Support macros for
10+ * - Armv8.3-A Pointer Authentication and
11+ * - Armv8.5-A Branch Target Identification
12+ * features which require emitting a .note.gnu.property section with the
13+ * appropriate architecture-dependent feature bits set.
14+ *
15+ * |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to
16+ * PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be
17+ * used immediately before saving the LR register (x30) to the stack.
18+ * |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring
19+ * it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone
20+ * with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also
21+ * have the same value at the two points. For example:
22+ *
23+ * .global f
24+ * f:
25+ * AARCH64_SIGN_LINK_REGISTER
26+ * stp x29, x30, [sp, #-96]!
27+ * mov x29, sp
28+ * ...
29+ * ldp x29, x30, [sp], #96
30+ * AARCH64_VALIDATE_LINK_REGISTER
31+ * ret
32+ *
33+ * |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or
34+ * |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an
35+ * indirect call target. In particular, all symbols exported from a file must
36+ * begin with one of these macros. For example, a leaf function that does not
37+ * save LR can instead use |AARCH64_VALID_CALL_TARGET|:
38+ *
39+ * .globl return_zero
40+ * return_zero:
41+ * AARCH64_VALID_CALL_TARGET
42+ * mov x0, #0
43+ * ret
44+ *
45+ * A non-leaf function which does not immediately save LR may need both macros
46+ * because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function
47+ * may jump to an alternate implementation before setting up the stack:
48+ *
49+ * .globl with_early_jump
50+ * with_early_jump:
51+ * AARCH64_VALID_CALL_TARGET
52+ * cmp x0, #128
53+ * b.lt .Lwith_early_jump_128
54+ * AARCH64_SIGN_LINK_REGISTER
55+ * stp x29, x30, [sp, #-96]!
56+ * mov x29, sp
57+ * ...
58+ * ldp x29, x30, [sp], #96
59+ * AARCH64_VALIDATE_LINK_REGISTER
60+ * ret
61+ *
62+ * .Lwith_early_jump_128:
63+ * ...
64+ * ret
65+ *
66+ * These annotations are only required with indirect calls. Private symbols that
67+ * are only the target of direct calls do not require annotations. Also note
68+ * that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not
69+ * indirect jumps (BR). Indirect jumps in assembly are supported through
70+ * |AARCH64_VALID_JUMP_TARGET|. Landing Pads which shall serve for jumps and
71+ * calls can be created using |AARCH64_VALID_JUMP_CALL_TARGET|.
72+ *
73+ * Although not necessary, it is safe to use these macros in 32-bit ARM
74+ * assembly. This may be used to simplify dual 32-bit and 64-bit files.
75+ *
76+ * References:
77+ * - "ELF for the Arm® 64-bit Architecture"
78+ * https: *github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst
79+ * - "Providing protection for complex software"
80+ * https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
81+ */
82+#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
83+# define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI
84+# define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c'
85+# define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j'
86+#else
87+# define GNU_PROPERTY_AARCH64_BTI 0 // No BTI
88+# define AARCH64_VALID_CALL_TARGET
89+# define AARCH64_VALID_JUMP_TARGET
90+#endif
91+
92+#if defined(__ARM_FEATURE_PAC_DEFAULT)
93+# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 0)) != 0) // authentication using key A
94+# define AARCH64_SIGN_LINK_REGISTER paciasp
95+# define AARCH64_VALIDATE_LINK_REGISTER autiasp
96+# elif ((__ARM_FEATURE_PAC_DEFAULT & (1 << 1)) != 0) // authentication using key B
97+# define AARCH64_SIGN_LINK_REGISTER pacibsp
98+# define AARCH64_VALIDATE_LINK_REGISTER autibsp
99+# else
100+# error Pointer authentication defines no valid key!
101+# endif
102+# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 2)) != 0)
103+# error Authentication of leaf functions is enabled but not supported in FFmpeg!
104+# endif
105+# define GNU_PROPERTY_AARCH64_PAC (1 << 1)
106+#else
107+# define GNU_PROPERTY_AARCH64_PAC 0
108+# define AARCH64_SIGN_LINK_REGISTER
109+# define AARCH64_VALIDATE_LINK_REGISTER
110+#endif
111+
112+
113+#if (GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_PAC != 0)
114+ .pushsection .note.gnu.property, "a"
115+ .balign 8
116+ .long 4
117+ .long 0x10
118+ .long 0x5
119+ .asciz "GNU"
120+ .long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
121+ .long 4
122+ .long (GNU_PROPERTY_AARCH64_BTI | GNU_PROPERTY_AARCH64_PAC)
123+ .long 0
124+ .popsection
125+#endif
126+
127 .macro function name, export=0, align=2
128 .macro endfunc
129 ELF .size \name, . - \name
130@@ -49,6 +168,7 @@ FUNC .endfunc
131 ELF .type EXTERN_ASM\name, %function
132 FUNC .func EXTERN_ASM\name
133 EXTERN_ASM\name:
134+ AARCH64_VALID_CALL_TARGET
135 .else
136 ELF .type \name, %function
137 FUNC .func \name
diff --git a/graphics/ffmpeg/patches/patch-libavutil_x86_x86inc_asm b/graphics/ffmpeg/patches/patch-libavutil_x86_x86inc_asm
new file mode 100644
index 0000000..ad08b16
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libavutil_x86_x86inc_asm
@@ -0,0 +1,27 @@
1- define _CET_ENDBR depending X86_64 / X86
2- use it in cglobal macro
3
4Index: libavutil/x86/x86inc.asm
5--- libavutil/x86/x86inc.asm.orig
6+++ libavutil/x86/x86inc.asm
7@@ -53,6 +53,12 @@
8 %endif
9 %endif
10
11+%if ARCH_X86_64
12+ %define _CET_ENDBR endbr64
13+%else
14+ %define _CET_ENDBR
15+%endif
16+
17 %define WIN64 0
18 %define UNIX64 0
19 %if ARCH_X86_64
20@@ -746,6 +752,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg,
21 %endif
22 align function_align
23 %2:
24+ _CET_ENDBR
25 RESET_MM_PERMUTATION ; needed for x86-64, also makes disassembly somewhat nicer
26 %xdefine rstk rsp ; copy of the original stack pointer, used when greater alignment than the known stack alignment is required
27 %assign stack_offset 0 ; stack pointer offset relative to the return address
diff --git a/graphics/ffmpeg/patches/patch-libswscale_ppc_yuv2rgb_altivec_c b/graphics/ffmpeg/patches/patch-libswscale_ppc_yuv2rgb_altivec_c
new file mode 100644
index 0000000..000fd91
--- /dev/null
+++ b/graphics/ffmpeg/patches/patch-libswscale_ppc_yuv2rgb_altivec_c
@@ -0,0 +1,14 @@
1error: redeclaration of 'vec_xl' must have the 'overloadable' attribute
2
3Index: libswscale/ppc/yuv2rgb_altivec.c
4--- libswscale/ppc/yuv2rgb_altivec.c.orig
5+++ libswscale/ppc/yuv2rgb_altivec.c
6@@ -284,7 +284,7 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector s
7 * ------------------------------------------------------------------------------
8 */
9
10-#if !HAVE_VSX
11+#if !HAVE_VSX && !defined(__clang__)
12 static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
13 {
14 const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset);
diff --git a/graphics/ffmpeg/pkg/CVS/Entries b/graphics/ffmpeg/pkg/CVS/Entries
new file mode 100644
index 0000000..93ad68c
--- /dev/null
+++ b/graphics/ffmpeg/pkg/CVS/Entries
@@ -0,0 +1,4 @@
1/DESCR/1.4/Sun Sep 4 09:22:43 2011//
2/README/1.3/Sat Mar 12 08:16:31 2022//
3/PLIST/1.42/Fri Dec 30 08:19:04 2022//
4D
diff --git a/graphics/ffmpeg/pkg/CVS/Repository b/graphics/ffmpeg/pkg/CVS/Repository
new file mode 100644
index 0000000..1b8a17a
--- /dev/null
+++ b/graphics/ffmpeg/pkg/CVS/Repository
@@ -0,0 +1 @@
ports/graphics/ffmpeg/pkg
diff --git a/graphics/ffmpeg/pkg/DESCR b/graphics/ffmpeg/pkg/DESCR
new file mode 100644
index 0000000..f890b18
--- /dev/null
+++ b/graphics/ffmpeg/pkg/DESCR
@@ -0,0 +1,2 @@
1FFmpeg is a complete solution to record, convert and stream audio and
2video. It includes libavcodec, the leading audio/video codec library.
diff --git a/graphics/ffmpeg/pkg/PLIST b/graphics/ffmpeg/pkg/PLIST
new file mode 100644
index 0000000..fc61159
--- /dev/null
+++ b/graphics/ffmpeg/pkg/PLIST
@@ -0,0 +1,249 @@
1@bin bin/ffmpeg
2@bin bin/ffplay
3@bin bin/ffprobe
4@bin bin/qt-faststart
5include/libavcodec/
6include/libavcodec/ac3_parser.h
7include/libavcodec/adts_parser.h
8include/libavcodec/avcodec.h
9include/libavcodec/avdct.h
10include/libavcodec/avfft.h
11include/libavcodec/bsf.h
12include/libavcodec/codec.h
13include/libavcodec/codec_desc.h
14include/libavcodec/codec_id.h
15include/libavcodec/codec_par.h
16include/libavcodec/d3d11va.h
17include/libavcodec/dirac.h
18include/libavcodec/dv_profile.h
19include/libavcodec/dxva2.h
20include/libavcodec/jni.h
21include/libavcodec/mediacodec.h
22include/libavcodec/packet.h
23include/libavcodec/qsv.h
24include/libavcodec/vaapi.h
25include/libavcodec/vdpau.h
26include/libavcodec/version.h
27include/libavcodec/videotoolbox.h
28include/libavcodec/vorbis_parser.h
29include/libavcodec/xvmc.h
30include/libavdevice/
31include/libavdevice/avdevice.h
32include/libavdevice/version.h
33include/libavfilter/
34include/libavfilter/avfilter.h
35include/libavfilter/buffersink.h
36include/libavfilter/buffersrc.h
37include/libavfilter/version.h
38include/libavformat/
39include/libavformat/avformat.h
40include/libavformat/avio.h
41include/libavformat/version.h
42include/libavutil/
43include/libavutil/adler32.h
44include/libavutil/aes.h
45include/libavutil/aes_ctr.h
46include/libavutil/attributes.h
47include/libavutil/audio_fifo.h
48include/libavutil/avassert.h
49include/libavutil/avconfig.h
50include/libavutil/avstring.h
51include/libavutil/avutil.h
52include/libavutil/base64.h
53include/libavutil/blowfish.h
54include/libavutil/bprint.h
55include/libavutil/bswap.h
56include/libavutil/buffer.h
57include/libavutil/camellia.h
58include/libavutil/cast5.h
59include/libavutil/channel_layout.h
60include/libavutil/common.h
61include/libavutil/cpu.h
62include/libavutil/crc.h
63include/libavutil/des.h
64include/libavutil/dict.h
65include/libavutil/display.h
66include/libavutil/dovi_meta.h
67include/libavutil/downmix_info.h
68include/libavutil/encryption_info.h
69include/libavutil/error.h
70include/libavutil/eval.h
71include/libavutil/ffversion.h
72include/libavutil/fifo.h
73include/libavutil/file.h
74include/libavutil/film_grain_params.h
75include/libavutil/frame.h
76include/libavutil/hash.h
77include/libavutil/hdr_dynamic_metadata.h
78include/libavutil/hmac.h
79include/libavutil/hwcontext.h
80include/libavutil/hwcontext_cuda.h
81include/libavutil/hwcontext_d3d11va.h
82include/libavutil/hwcontext_drm.h
83include/libavutil/hwcontext_dxva2.h
84include/libavutil/hwcontext_mediacodec.h
85include/libavutil/hwcontext_opencl.h
86include/libavutil/hwcontext_qsv.h
87include/libavutil/hwcontext_vaapi.h
88include/libavutil/hwcontext_vdpau.h
89include/libavutil/hwcontext_videotoolbox.h
90include/libavutil/hwcontext_vulkan.h
91include/libavutil/imgutils.h
92include/libavutil/intfloat.h
93include/libavutil/intreadwrite.h
94include/libavutil/lfg.h
95include/libavutil/log.h
96include/libavutil/lzo.h
97include/libavutil/macros.h
98include/libavutil/mastering_display_metadata.h
99include/libavutil/mathematics.h
100include/libavutil/md5.h
101include/libavutil/mem.h
102include/libavutil/motion_vector.h
103include/libavutil/murmur3.h
104include/libavutil/opt.h
105include/libavutil/parseutils.h
106include/libavutil/pixdesc.h
107include/libavutil/pixelutils.h
108include/libavutil/pixfmt.h
109include/libavutil/random_seed.h
110include/libavutil/rational.h
111include/libavutil/rc4.h
112include/libavutil/replaygain.h
113include/libavutil/ripemd.h
114include/libavutil/samplefmt.h
115include/libavutil/sha.h
116include/libavutil/sha512.h
117include/libavutil/spherical.h
118include/libavutil/stereo3d.h
119include/libavutil/tea.h
120include/libavutil/threadmessage.h
121include/libavutil/time.h
122include/libavutil/timecode.h
123include/libavutil/timestamp.h
124include/libavutil/tree.h
125include/libavutil/twofish.h
126include/libavutil/tx.h
127include/libavutil/version.h
128include/libavutil/video_enc_params.h
129include/libavutil/xtea.h
130include/libpostproc/
131include/libpostproc/postprocess.h
132include/libpostproc/version.h
133include/libswresample/
134include/libswresample/swresample.h
135include/libswresample/version.h
136include/libswscale/
137include/libswscale/swscale.h
138include/libswscale/version.h
139@static-lib lib/libavcodec.a
140@lib lib/libavcodec.so.${LIBavcodec_VERSION}
141@static-lib lib/libavdevice.a
142@lib lib/libavdevice.so.${LIBavdevice_VERSION}
143@static-lib lib/libavfilter.a
144@lib lib/libavfilter.so.${LIBavfilter_VERSION}
145@static-lib lib/libavformat.a
146@lib lib/libavformat.so.${LIBavformat_VERSION}
147@static-lib lib/libavutil.a
148@lib lib/libavutil.so.${LIBavutil_VERSION}
149@static-lib lib/libpostproc.a
150@lib lib/libpostproc.so.${LIBpostproc_VERSION}
151@static-lib lib/libswresample.a
152@lib lib/libswresample.so.${LIBswresample_VERSION}
153@static-lib lib/libswscale.a
154@lib lib/libswscale.so.${LIBswscale_VERSION}
155lib/pkgconfig/libavcodec.pc
156lib/pkgconfig/libavdevice.pc
157lib/pkgconfig/libavfilter.pc
158lib/pkgconfig/libavformat.pc
159lib/pkgconfig/libavutil.pc
160lib/pkgconfig/libpostproc.pc
161lib/pkgconfig/libswresample.pc
162lib/pkgconfig/libswscale.pc
163@man man/man1/ffmpeg-all.1
164@man man/man1/ffmpeg-bitstream-filters.1
165@man man/man1/ffmpeg-codecs.1
166@man man/man1/ffmpeg-devices.1
167@man man/man1/ffmpeg-filters.1
168@man man/man1/ffmpeg-formats.1
169@man man/man1/ffmpeg-protocols.1
170@man man/man1/ffmpeg-resampler.1
171@man man/man1/ffmpeg-scaler.1
172@man man/man1/ffmpeg-utils.1
173@man man/man1/ffmpeg.1
174@man man/man1/ffplay-all.1
175@man man/man1/ffplay.1
176@man man/man1/ffprobe-all.1
177@man man/man1/ffprobe.1
178@man man/man3/libavcodec.3
179@man man/man3/libavdevice.3
180@man man/man3/libavfilter.3
181@man man/man3/libavformat.3
182@man man/man3/libavutil.3
183@man man/man3/libswresample.3
184@man man/man3/libswscale.3
185share/doc/ffmpeg/
186share/doc/ffmpeg/developer.html
187share/doc/ffmpeg/faq.html
188share/doc/ffmpeg/fate.html
189share/doc/ffmpeg/ffmpeg-all.html
190share/doc/ffmpeg/ffmpeg-bitstream-filters.html
191share/doc/ffmpeg/ffmpeg-codecs.html
192share/doc/ffmpeg/ffmpeg-devices.html
193share/doc/ffmpeg/ffmpeg-filters.html
194share/doc/ffmpeg/ffmpeg-formats.html
195share/doc/ffmpeg/ffmpeg-protocols.html
196share/doc/ffmpeg/ffmpeg-resampler.html
197share/doc/ffmpeg/ffmpeg-scaler.html
198share/doc/ffmpeg/ffmpeg-utils.html
199share/doc/ffmpeg/ffmpeg.html
200share/doc/ffmpeg/ffplay-all.html
201share/doc/ffmpeg/ffplay.html
202share/doc/ffmpeg/ffprobe-all.html
203share/doc/ffmpeg/ffprobe.html
204share/doc/ffmpeg/general.html
205share/doc/ffmpeg/git-howto.html
206share/doc/ffmpeg/libavcodec.html
207share/doc/ffmpeg/libavdevice.html
208share/doc/ffmpeg/libavfilter.html
209share/doc/ffmpeg/libavformat.html
210share/doc/ffmpeg/libavutil.html
211share/doc/ffmpeg/libswresample.html
212share/doc/ffmpeg/libswscale.html
213share/doc/ffmpeg/mailing-list-faq.html
214share/doc/ffmpeg/nut.html
215share/doc/ffmpeg/platform.html
216share/doc/pkg-readmes/${PKGSTEM}
217share/examples/ffmpeg/
218share/examples/ffmpeg/Makefile
219share/examples/ffmpeg/README
220share/examples/ffmpeg/avio_list_dir.c
221share/examples/ffmpeg/avio_reading.c
222share/examples/ffmpeg/decode_audio.c
223share/examples/ffmpeg/decode_video.c
224share/examples/ffmpeg/demuxing_decoding.c
225share/examples/ffmpeg/encode_audio.c
226share/examples/ffmpeg/encode_video.c
227share/examples/ffmpeg/extract_mvs.c
228share/examples/ffmpeg/filter_audio.c
229share/examples/ffmpeg/filtering_audio.c
230share/examples/ffmpeg/filtering_video.c
231share/examples/ffmpeg/http_multiclient.c
232share/examples/ffmpeg/hw_decode.c
233share/examples/ffmpeg/metadata.c
234share/examples/ffmpeg/muxing.c
235share/examples/ffmpeg/qsvdec.c
236share/examples/ffmpeg/remuxing.c
237share/examples/ffmpeg/resampling_audio.c
238share/examples/ffmpeg/scaling_video.c
239share/examples/ffmpeg/transcode_aac.c
240share/examples/ffmpeg/transcoding.c
241share/examples/ffmpeg/vaapi_encode.c
242share/examples/ffmpeg/vaapi_transcode.c
243share/ffmpeg/
244share/ffmpeg/ffprobe.xsd
245share/ffmpeg/libvpx-1080p.ffpreset
246share/ffmpeg/libvpx-1080p50_60.ffpreset
247share/ffmpeg/libvpx-360p.ffpreset
248share/ffmpeg/libvpx-720p.ffpreset
249share/ffmpeg/libvpx-720p50_60.ffpreset
diff --git a/graphics/ffmpeg/pkg/README b/graphics/ffmpeg/pkg/README
new file mode 100644
index 0000000..9876c4f
--- /dev/null
+++ b/graphics/ffmpeg/pkg/README
@@ -0,0 +1,18 @@
1+-----------------------------------------------------------------------
2| Running ${PKGSTEM} on OpenBSD
3+-----------------------------------------------------------------------
4
5bktr(4) support (amd64/i386/powerpc only) may be controlled through the
6following environment variables:
7
8BKTR_DEV={0|1|2|3|4}: Selects device input (tuner, camera, ...)
9
10BKTR_FORMAT={1|2|3|4|5|6}:
11 1 PAL
12 2 NTSC
13 3 SECAM
14 4 PALN
15 5 PALM
16 6 NTSCJ
17
18BKTR_FREQUENCY=xxx.yy: Sets frequency in MHz