summaryrefslogtreecommitdiff
path: root/multimedia
diff options
context:
space:
mode:
authorryoon <ryoon@pkgsrc.org>2022-01-31 23:16:41 +0000
committerryoon <ryoon@pkgsrc.org>2022-01-31 23:16:41 +0000
commitb187fadef05c9d3fdf11b03a0b17ff00afe54651 (patch)
treefc5a9ab618e15240c1a7368b37440c9950550e3d /multimedia
parent51eddbf40de6f372cccd23b697f370e098d63515 (diff)
downloadpkgsrc-b187fadef05c9d3fdf11b03a0b17ff00afe54651.tar.gz
multimedia/ffmpeg5: import ffmpeg5-5.0
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. This package contains major version 5.
Diffstat (limited to 'multimedia')
-rw-r--r--multimedia/ffmpeg5/ALTERNATIVES2
-rw-r--r--multimedia/ffmpeg5/DESCR5
-rw-r--r--multimedia/ffmpeg5/Makefile44
-rw-r--r--multimedia/ffmpeg5/Makefile.common85
-rw-r--r--multimedia/ffmpeg5/PLIST266
-rw-r--r--multimedia/ffmpeg5/buildlink3.mk63
-rw-r--r--multimedia/ffmpeg5/distinfo20
-rw-r--r--multimedia/ffmpeg5/options.mk279
-rw-r--r--multimedia/ffmpeg5/patches/patch-Makefile15
-rw-r--r--multimedia/ffmpeg5/patches/patch-configure78
-rw-r--r--multimedia/ffmpeg5/patches/patch-doc_Makefile31
-rw-r--r--multimedia/ffmpeg5/patches/patch-doc_general__contents.texi14
-rw-r--r--multimedia/ffmpeg5/patches/patch-doc_indevs.texi42
-rw-r--r--multimedia/ffmpeg5/patches/patch-doc_outdevs.texi24
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_Makefile15
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_alldevices.c15
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_sunau.c109
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_sunau.h55
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_sunau__dec.c145
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavdevice_sunau__enc.c121
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavutil_macros.h29
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavutil_x86_asm.h18
-rw-r--r--multimedia/ffmpeg5/patches/patch-libavutil_x86_cpu.c22
23 files changed, 1497 insertions, 0 deletions
diff --git a/multimedia/ffmpeg5/ALTERNATIVES b/multimedia/ffmpeg5/ALTERNATIVES
new file mode 100644
index 00000000000..976b571fbab
--- /dev/null
+++ b/multimedia/ffmpeg5/ALTERNATIVES
@@ -0,0 +1,2 @@
+bin/ffmpeg @PREFIX@/bin/ffmpeg5
+bin/ffprobe @PREFIX@/bin/ffprobe5
diff --git a/multimedia/ffmpeg5/DESCR b/multimedia/ffmpeg5/DESCR
new file mode 100644
index 00000000000..9c6a127fecd
--- /dev/null
+++ b/multimedia/ffmpeg5/DESCR
@@ -0,0 +1,5 @@
+FFmpeg is a complete, cross-platform solution to record, convert
+and stream audio and video. It includes libavcodec - the leading
+audio/video codec library.
+
+This package contains major version 5.
diff --git a/multimedia/ffmpeg5/Makefile b/multimedia/ffmpeg5/Makefile
new file mode 100644
index 00000000000..e531e11d698
--- /dev/null
+++ b/multimedia/ffmpeg5/Makefile
@@ -0,0 +1,44 @@
+# $NetBSD: Makefile,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+PKGNAME= ${DISTNAME:S/ffmpeg/ffmpeg5/}
+MAINTAINER= pkgsrc-users@NetBSD.org
+HOMEPAGE= https://ffmpeg.org/
+COMMENT= Decoding, encoding and streaming software (v5.x)
+
+CONFIGURE_ARGS+= --enable-avfilter
+CONFIGURE_ARGS+= --enable-postproc
+CONFIGURE_ARGS+= --enable-rpath
+CONFIGURE_ARGS+= --disable-ffplay
+
+INSTALLATION_DIRS= lib/ffmpeg5 share/doc/ffmpeg5 share/examples/ffmpeg5
+
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
+CONFIGURE_ARGS+= --enable-cross-compile
+CONFIGURE_ARGS+= --host-cc=${NATIVE_CC:Q}
+CONFIGURE_ARGS+= --host-ld=${NATIVE_CC:Q}
+CONFIGURE_ARGS+= --target-os=${LOWER_OPSYS}
+.endif
+
+PRINT_PLIST_AWK+= /html/ { $$0 = "$${PLIST.doc}" $$0 }
+
+TEST_TARGET= check
+
+post-install:
+ ${INSTALL_DATA} ${WRKSRC}/doc/*.txt \
+ ${DESTDIR}${PREFIX}/share/doc/ffmpeg5
+
+.include "options.mk"
+
+# disable asm on i386 to avoid text relocations
+.if ${MACHINE_ARCH} == "i386"
+CONFIGURE_ARGS+= --disable-asm
+.endif
+
+# configure script uses uname -m to detect arch, as opposed to uname -p in
+# GNU/configure. Unable to detect NetBSD/macppc hosts correctly.
+CONFIGURE_ARGS+= --arch=${MACHINE_ARCH}
+
+.include "../../multimedia/ffmpeg5/Makefile.common"
+.include "../../mk/bsd.pkg.mk"
diff --git a/multimedia/ffmpeg5/Makefile.common b/multimedia/ffmpeg5/Makefile.common
new file mode 100644
index 00000000000..3c58edf9e43
--- /dev/null
+++ b/multimedia/ffmpeg5/Makefile.common
@@ -0,0 +1,85 @@
+# $NetBSD: Makefile.common,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+# used by multimedia/ffmpeg5/Makefile
+# used by multimedia/ffplay5/Makefile
+
+DISTNAME= ffmpeg-5.0
+CATEGORIES= multimedia
+MASTER_SITES= http://www.ffmpeg.org/releases/
+EXTRACT_SUFX= .tar.xz
+
+LICENSE= gnu-lgpl-v2.1 AND gnu-gpl-v2 ${ADDITIONAL_LICENSE}
+
+PATCHDIR= ${.CURDIR}/../../multimedia/ffmpeg5/patches
+
+USE_LIBTOOL= yes
+USE_TOOLS+= gmake pod2man perl pkg-config
+HAS_CONFIGURE= yes
+CONFIGURE_ARGS+= --cc=${CC:Q}
+CONFIGURE_ARGS+= --disable-debug
+CONFIGURE_ARGS+= --disable-optimizations
+CONFIGURE_ARGS+= --disable-stripping
+CONFIGURE_ARGS+= --enable-gpl
+CONFIGURE_ARGS+= --enable-libxml2
+CONFIGURE_ARGS+= --enable-pthreads
+CONFIGURE_ARGS+= --enable-shared
+CONFIGURE_ARGS+= --mandir=${PREFIX}/${PKGMANDIR}
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+
+CONFIGURE_ARGS+= --progs-suffix=5
+CONFIGURE_ARGS+= --datadir=${PREFIX}/share/ffmpeg5
+CONFIGURE_ARGS+= --docdir=${PREFIX}/share/doc/ffmpeg5
+CONFIGURE_ARGS+= --incdir=${PREFIX}/include/ffmpeg5
+CONFIGURE_ARGS+= --libdir=${PREFIX}/lib/ffmpeg5
+CONFIGURE_ARGS+= --shlibdir=${PREFIX}/lib/ffmpeg5
+LDFLAGS+= ${COMPILER_RPATH_FLAG}${PREFIX}/lib/ffmpeg5
+
+.if !empty(MACHINE_PLATFORM:MDarwin-1[2-9].*-*) || !empty(MACHINE_PLATFORM:MDarwin-2*)
+CONFIGURE_ARGS+= --enable-opencl
+.endif
+
+.if ${OPSYS} == "SunOS"
+USE_TOOLS+= bash:build
+CONFIG_SHELL= ${TOOLS_PATH.bash}
+.endif
+
+CONFIGURE_ARGS+= --enable-runtime-cpudetect
+
+# Let's not put garbage into /tmp
+CONFIGURE_ENV+= TMPDIR=${WRKSRC}/tmp
+
+.include "../../mk/compiler.mk"
+
+.if !empty(PKGSRC_COMPILER:Msunpro)
+SUBST_CLASSES+= sunwspro
+SUBST_MESSAGE.sunwspro= Fixing compiler options for SunStudio C compiler.
+SUBST_STAGE.sunwspro= post-configure
+SUBST_FILES.sunwspro= config.mak
+SUBST_SED.sunwspro= -e "s/-O /-KPIC -DPIC /"
+SUBST_SED.sunwspro+= -e "s/-O3/-xO2/g"
+SUBST_SED.sunwspro+= -e "s/-std=c99/-xc99=all/"
+SUBST_SED.sunwspro+= -e "s/-Wl,-rpath-link,/-L /g"
+.endif
+
+.if ${MACHINE_ARCH} == x86_64 || ${MACHINE_ARCH} == i386
+BUILD_DEPENDS+= nasm>=2.13:../../devel/nasm
+.endif
+
+REPLACE_PERL+= doc/texi2pod.pl
+REPLACE_SH+= configure
+REPLACE_SH+= ffbuild/pkgconfig_generate.sh
+REPLACE_SH+= ffbuild/version.sh
+
+PLIST_SRC+= ${PKGDIR}/PLIST
+
+MAKE_ENV+= EXTRA_LIBS=${LIBGETOPT:Q}
+
+pre-configure:
+ mkdir ${WRKSRC}/tmp
+
+.include "../../archivers/bzip2/buildlink3.mk"
+.include "../../archivers/xz/buildlink3.mk"
+.include "../../devel/libgetopt/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../textproc/libxml2/buildlink3.mk"
+.include "../../mk/atomic64.mk"
+.include "../../mk/pthread.buildlink3.mk"
diff --git a/multimedia/ffmpeg5/PLIST b/multimedia/ffmpeg5/PLIST
new file mode 100644
index 00000000000..612bad1c735
--- /dev/null
+++ b/multimedia/ffmpeg5/PLIST
@@ -0,0 +1,266 @@
+@comment $NetBSD: PLIST,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+bin/ffmpeg5
+bin/ffprobe5
+include/ffmpeg5/libavcodec/ac3_parser.h
+include/ffmpeg5/libavcodec/adts_parser.h
+include/ffmpeg5/libavcodec/avcodec.h
+include/ffmpeg5/libavcodec/avdct.h
+include/ffmpeg5/libavcodec/avfft.h
+include/ffmpeg5/libavcodec/bsf.h
+include/ffmpeg5/libavcodec/codec.h
+include/ffmpeg5/libavcodec/codec_desc.h
+include/ffmpeg5/libavcodec/codec_id.h
+include/ffmpeg5/libavcodec/codec_par.h
+include/ffmpeg5/libavcodec/d3d11va.h
+include/ffmpeg5/libavcodec/defs.h
+include/ffmpeg5/libavcodec/dirac.h
+include/ffmpeg5/libavcodec/dv_profile.h
+include/ffmpeg5/libavcodec/dxva2.h
+include/ffmpeg5/libavcodec/jni.h
+include/ffmpeg5/libavcodec/mediacodec.h
+include/ffmpeg5/libavcodec/packet.h
+include/ffmpeg5/libavcodec/qsv.h
+include/ffmpeg5/libavcodec/vdpau.h
+include/ffmpeg5/libavcodec/version.h
+include/ffmpeg5/libavcodec/videotoolbox.h
+include/ffmpeg5/libavcodec/vorbis_parser.h
+include/ffmpeg5/libavcodec/xvmc.h
+include/ffmpeg5/libavdevice/avdevice.h
+include/ffmpeg5/libavdevice/version.h
+include/ffmpeg5/libavfilter/avfilter.h
+include/ffmpeg5/libavfilter/buffersink.h
+include/ffmpeg5/libavfilter/buffersrc.h
+include/ffmpeg5/libavfilter/version.h
+include/ffmpeg5/libavformat/avformat.h
+include/ffmpeg5/libavformat/avio.h
+include/ffmpeg5/libavformat/version.h
+include/ffmpeg5/libavutil/adler32.h
+include/ffmpeg5/libavutil/aes.h
+include/ffmpeg5/libavutil/aes_ctr.h
+include/ffmpeg5/libavutil/attributes.h
+include/ffmpeg5/libavutil/audio_fifo.h
+include/ffmpeg5/libavutil/avassert.h
+include/ffmpeg5/libavutil/avconfig.h
+include/ffmpeg5/libavutil/avstring.h
+include/ffmpeg5/libavutil/avutil.h
+include/ffmpeg5/libavutil/base64.h
+include/ffmpeg5/libavutil/blowfish.h
+include/ffmpeg5/libavutil/bprint.h
+include/ffmpeg5/libavutil/bswap.h
+include/ffmpeg5/libavutil/buffer.h
+include/ffmpeg5/libavutil/camellia.h
+include/ffmpeg5/libavutil/cast5.h
+include/ffmpeg5/libavutil/channel_layout.h
+include/ffmpeg5/libavutil/common.h
+include/ffmpeg5/libavutil/cpu.h
+include/ffmpeg5/libavutil/crc.h
+include/ffmpeg5/libavutil/des.h
+include/ffmpeg5/libavutil/detection_bbox.h
+include/ffmpeg5/libavutil/dict.h
+include/ffmpeg5/libavutil/display.h
+include/ffmpeg5/libavutil/dovi_meta.h
+include/ffmpeg5/libavutil/downmix_info.h
+include/ffmpeg5/libavutil/encryption_info.h
+include/ffmpeg5/libavutil/error.h
+include/ffmpeg5/libavutil/eval.h
+include/ffmpeg5/libavutil/ffversion.h
+include/ffmpeg5/libavutil/fifo.h
+include/ffmpeg5/libavutil/file.h
+include/ffmpeg5/libavutil/film_grain_params.h
+include/ffmpeg5/libavutil/frame.h
+include/ffmpeg5/libavutil/hash.h
+include/ffmpeg5/libavutil/hdr_dynamic_metadata.h
+include/ffmpeg5/libavutil/hmac.h
+include/ffmpeg5/libavutil/hwcontext.h
+include/ffmpeg5/libavutil/hwcontext_cuda.h
+include/ffmpeg5/libavutil/hwcontext_d3d11va.h
+include/ffmpeg5/libavutil/hwcontext_drm.h
+include/ffmpeg5/libavutil/hwcontext_dxva2.h
+include/ffmpeg5/libavutil/hwcontext_mediacodec.h
+include/ffmpeg5/libavutil/hwcontext_opencl.h
+include/ffmpeg5/libavutil/hwcontext_qsv.h
+include/ffmpeg5/libavutil/hwcontext_vaapi.h
+include/ffmpeg5/libavutil/hwcontext_vdpau.h
+include/ffmpeg5/libavutil/hwcontext_videotoolbox.h
+include/ffmpeg5/libavutil/hwcontext_vulkan.h
+include/ffmpeg5/libavutil/imgutils.h
+include/ffmpeg5/libavutil/intfloat.h
+include/ffmpeg5/libavutil/intreadwrite.h
+include/ffmpeg5/libavutil/lfg.h
+include/ffmpeg5/libavutil/log.h
+include/ffmpeg5/libavutil/lzo.h
+include/ffmpeg5/libavutil/macros.h
+include/ffmpeg5/libavutil/mastering_display_metadata.h
+include/ffmpeg5/libavutil/mathematics.h
+include/ffmpeg5/libavutil/md5.h
+include/ffmpeg5/libavutil/mem.h
+include/ffmpeg5/libavutil/motion_vector.h
+include/ffmpeg5/libavutil/murmur3.h
+include/ffmpeg5/libavutil/opt.h
+include/ffmpeg5/libavutil/parseutils.h
+include/ffmpeg5/libavutil/pixdesc.h
+include/ffmpeg5/libavutil/pixelutils.h
+include/ffmpeg5/libavutil/pixfmt.h
+include/ffmpeg5/libavutil/random_seed.h
+include/ffmpeg5/libavutil/rational.h
+include/ffmpeg5/libavutil/rc4.h
+include/ffmpeg5/libavutil/replaygain.h
+include/ffmpeg5/libavutil/ripemd.h
+include/ffmpeg5/libavutil/samplefmt.h
+include/ffmpeg5/libavutil/sha.h
+include/ffmpeg5/libavutil/sha512.h
+include/ffmpeg5/libavutil/spherical.h
+include/ffmpeg5/libavutil/stereo3d.h
+include/ffmpeg5/libavutil/tea.h
+include/ffmpeg5/libavutil/threadmessage.h
+include/ffmpeg5/libavutil/time.h
+include/ffmpeg5/libavutil/timecode.h
+include/ffmpeg5/libavutil/timestamp.h
+include/ffmpeg5/libavutil/tree.h
+include/ffmpeg5/libavutil/twofish.h
+include/ffmpeg5/libavutil/tx.h
+include/ffmpeg5/libavutil/version.h
+include/ffmpeg5/libavutil/video_enc_params.h
+include/ffmpeg5/libavutil/xtea.h
+include/ffmpeg5/libpostproc/postprocess.h
+include/ffmpeg5/libpostproc/version.h
+include/ffmpeg5/libswresample/swresample.h
+include/ffmpeg5/libswresample/version.h
+include/ffmpeg5/libswscale/swscale.h
+include/ffmpeg5/libswscale/version.h
+lib/ffmpeg5/libavcodec.a
+lib/ffmpeg5/libavcodec.so
+lib/ffmpeg5/libavcodec.so.59
+lib/ffmpeg5/libavcodec.so.59.18.100
+lib/ffmpeg5/libavdevice.a
+lib/ffmpeg5/libavdevice.so
+lib/ffmpeg5/libavdevice.so.59
+lib/ffmpeg5/libavdevice.so.59.4.100
+lib/ffmpeg5/libavfilter.a
+lib/ffmpeg5/libavfilter.so
+lib/ffmpeg5/libavfilter.so.8
+lib/ffmpeg5/libavfilter.so.8.24.100
+lib/ffmpeg5/libavformat.a
+lib/ffmpeg5/libavformat.so
+lib/ffmpeg5/libavformat.so.59
+lib/ffmpeg5/libavformat.so.59.16.100
+lib/ffmpeg5/libavutil.a
+lib/ffmpeg5/libavutil.so
+lib/ffmpeg5/libavutil.so.57
+lib/ffmpeg5/libavutil.so.57.17.100
+lib/ffmpeg5/libpostproc.a
+lib/ffmpeg5/libpostproc.so
+lib/ffmpeg5/libpostproc.so.56
+lib/ffmpeg5/libpostproc.so.56.3.100
+lib/ffmpeg5/libswresample.a
+lib/ffmpeg5/libswresample.so
+lib/ffmpeg5/libswresample.so.4
+lib/ffmpeg5/libswresample.so.4.3.100
+lib/ffmpeg5/libswscale.a
+lib/ffmpeg5/libswscale.so
+lib/ffmpeg5/libswscale.so.6
+lib/ffmpeg5/libswscale.so.6.4.100
+lib/ffmpeg5/pkgconfig/libavcodec.pc
+lib/ffmpeg5/pkgconfig/libavdevice.pc
+lib/ffmpeg5/pkgconfig/libavfilter.pc
+lib/ffmpeg5/pkgconfig/libavformat.pc
+lib/ffmpeg5/pkgconfig/libavutil.pc
+lib/ffmpeg5/pkgconfig/libpostproc.pc
+lib/ffmpeg5/pkgconfig/libswresample.pc
+lib/ffmpeg5/pkgconfig/libswscale.pc
+man/man1/ffmpeg-all5.1
+man/man1/ffmpeg-bitstream-filters5.1
+man/man1/ffmpeg-codecs5.1
+man/man1/ffmpeg-devices5.1
+man/man1/ffmpeg-filters5.1
+man/man1/ffmpeg-formats5.1
+man/man1/ffmpeg-protocols5.1
+man/man1/ffmpeg-resampler5.1
+man/man1/ffmpeg-scaler5.1
+man/man1/ffmpeg-utils5.1
+man/man1/ffmpeg5.1
+man/man1/ffprobe-all5.1
+man/man1/ffprobe5.1
+man/man3/libavcodec5.3
+man/man3/libavdevice5.3
+man/man3/libavfilter5.3
+man/man3/libavformat5.3
+man/man3/libavutil5.3
+man/man3/libswresample5.3
+man/man3/libswscale5.3
+share/doc/ffmpeg5/build_system.txt
+${PLIST.doc}share/doc/ffmpeg5/developer.html
+share/doc/ffmpeg5/errno.txt
+${PLIST.doc}share/doc/ffmpeg5/faq.html
+${PLIST.doc}share/doc/ffmpeg5/fate.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-all.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-bitstream-filters.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-codecs.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-devices.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-filters.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-formats.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-protocols.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-resampler.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-scaler.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg-utils.html
+${PLIST.doc}share/doc/ffmpeg5/ffmpeg.html
+share/doc/ffmpeg5/ffmpeg.txt
+${PLIST.doc}share/doc/ffmpeg5/ffprobe-all.html
+${PLIST.doc}share/doc/ffmpeg5/ffprobe.html
+share/doc/ffmpeg5/filter_design.txt
+${PLIST.doc}share/doc/ffmpeg5/general.html
+${PLIST.doc}share/doc/ffmpeg5/git-howto.html
+share/doc/ffmpeg5/issue_tracker.txt
+share/doc/ffmpeg5/libav-merge.txt
+${PLIST.doc}share/doc/ffmpeg5/libavcodec.html
+${PLIST.doc}share/doc/ffmpeg5/libavdevice.html
+${PLIST.doc}share/doc/ffmpeg5/libavfilter.html
+${PLIST.doc}share/doc/ffmpeg5/libavformat.html
+${PLIST.doc}share/doc/ffmpeg5/libavutil.html
+${PLIST.doc}share/doc/ffmpeg5/libswresample.html
+${PLIST.doc}share/doc/ffmpeg5/libswscale.html
+${PLIST.doc}share/doc/ffmpeg5/mailing-list-faq.html
+share/doc/ffmpeg5/mips.txt
+share/doc/ffmpeg5/multithreading.txt
+${PLIST.doc}share/doc/ffmpeg5/nut.html
+share/doc/ffmpeg5/optimization.txt
+${PLIST.doc}share/doc/ffmpeg5/platform.html
+share/doc/ffmpeg5/rate_distortion.txt
+share/doc/ffmpeg5/snow.txt
+share/doc/ffmpeg5/swresample.txt
+share/doc/ffmpeg5/swscale.txt
+share/doc/ffmpeg5/tablegen.txt
+share/doc/ffmpeg5/undefined.txt
+share/doc/ffmpeg5/writing_filters.txt
+share/ffmpeg5/examples/Makefile
+share/ffmpeg5/examples/README
+share/ffmpeg5/examples/avio_list_dir.c
+share/ffmpeg5/examples/avio_reading.c
+share/ffmpeg5/examples/decode_audio.c
+share/ffmpeg5/examples/decode_video.c
+share/ffmpeg5/examples/demuxing_decoding.c
+share/ffmpeg5/examples/encode_audio.c
+share/ffmpeg5/examples/encode_video.c
+share/ffmpeg5/examples/extract_mvs.c
+share/ffmpeg5/examples/filter_audio.c
+share/ffmpeg5/examples/filtering_audio.c
+share/ffmpeg5/examples/filtering_video.c
+share/ffmpeg5/examples/http_multiclient.c
+share/ffmpeg5/examples/hw_decode.c
+share/ffmpeg5/examples/metadata.c
+share/ffmpeg5/examples/muxing.c
+share/ffmpeg5/examples/qsvdec.c
+share/ffmpeg5/examples/remuxing.c
+share/ffmpeg5/examples/resampling_audio.c
+share/ffmpeg5/examples/scaling_video.c
+share/ffmpeg5/examples/transcode_aac.c
+share/ffmpeg5/examples/transcoding.c
+share/ffmpeg5/examples/vaapi_encode.c
+share/ffmpeg5/examples/vaapi_transcode.c
+share/ffmpeg5/ffprobe.xsd
+share/ffmpeg5/libvpx-1080p.ffpreset
+share/ffmpeg5/libvpx-1080p50_60.ffpreset
+share/ffmpeg5/libvpx-360p.ffpreset
+share/ffmpeg5/libvpx-720p.ffpreset
+share/ffmpeg5/libvpx-720p50_60.ffpreset
+@pkgdir share/examples/ffmpeg5
diff --git a/multimedia/ffmpeg5/buildlink3.mk b/multimedia/ffmpeg5/buildlink3.mk
new file mode 100644
index 00000000000..e7f845dd6a3
--- /dev/null
+++ b/multimedia/ffmpeg5/buildlink3.mk
@@ -0,0 +1,63 @@
+# $NetBSD: buildlink3.mk,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+BUILDLINK_TREE+= ffmpeg5
+
+.if !defined(FFMPEG5_BUILDLINK3_MK)
+FFMPEG5_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.ffmpeg5+= ffmpeg5>=5.0
+BUILDLINK_ABI_DEPENDS.ffmpeg5+= ffmpeg5>=5.0
+BUILDLINK_PKGSRCDIR.ffmpeg5?= ../../multimedia/ffmpeg5
+
+pkgbase := ffmpeg5
+.include "../../mk/pkg-build-options.mk"
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mav1}
+. include "../../multimedia/libaom/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mfreetype}
+. include "../../graphics/freetype2/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mfontconfig}
+. include "../../fonts/fontconfig/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mtheora}
+. include "../../multimedia/libtheora/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mxvid}
+. include "../../multimedia/xvidcore/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mx264}
+. include "../../multimedia/x264-devel/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mlibvpx}
+. include "../../multimedia/libvpx/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mvaapi}
+. include "../../multimedia/libva/buildlink3.mk"
+.endif
+
+.if ${PKG_BUILD_OPTIONS.ffmpeg5:Mvdpau}
+. include "../../multimedia/libvdpau/buildlink3.mk"
+.endif
+
+BUILDLINK_INCDIRS.ffmpeg5+= include/ffmpeg5
+BUILDLINK_LIBDIRS.ffmpeg5+= lib/ffmpeg5
+BUILDLINK_FNAME_TRANSFORM.ffmpeg5+= -e 's|lib/ffmpeg5/pkgconfig/|lib/pkgconfig/|'
+
+.include "../../archivers/bzip2/buildlink3.mk"
+.include "../../archivers/xz/buildlink3.mk"
+.include "../../devel/libgetopt/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.endif # FFMPEG5_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -ffmpeg5
diff --git a/multimedia/ffmpeg5/distinfo b/multimedia/ffmpeg5/distinfo
new file mode 100644
index 00000000000..0579175dee9
--- /dev/null
+++ b/multimedia/ffmpeg5/distinfo
@@ -0,0 +1,20 @@
+$NetBSD: distinfo,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+BLAKE2s (ffmpeg-5.0.tar.xz) = 978127fece2cd1765ee14902bf7d5abce715baeaa80b58acd00f8eff38acf6e6
+SHA512 (ffmpeg-5.0.tar.xz) = 112bdd566243927000c6f78dbb3a2ba045f66ec24150c691c993a73ef6da1ab3978b403af6f8149f95dbdcfd2d82b4e539b83ee39af89b0137638351c9f1bae7
+Size (ffmpeg-5.0.tar.xz) = 9811480 bytes
+SHA1 (patch-Makefile) = 2d27f218ee49179fdea14bb5c86c506dfb64dbd6
+SHA1 (patch-configure) = 9ec024b5b6df0b9a5111b5b47801c30f5ad911ea
+SHA1 (patch-doc_Makefile) = d45fc311f47e6cd8a8432659d7bd77e50b858e43
+SHA1 (patch-doc_general__contents.texi) = 13704795d2688dc0377a512dc6e65025ad674724
+SHA1 (patch-doc_indevs.texi) = 8cd421a67f34ebbe6099102bf1de7c6cdb13dcb7
+SHA1 (patch-doc_outdevs.texi) = 0aec04682b516016abe9b81f6efcbbef97b1c3b2
+SHA1 (patch-libavdevice_Makefile) = 526efd20021068245d8904c0d55508a540ae4054
+SHA1 (patch-libavdevice_alldevices.c) = 1d12f5b12d37a73512cd8e0f05272e9a64588e49
+SHA1 (patch-libavdevice_sunau.c) = 44dba866c58d508c0f873ffdd9ad8d25c059cc8a
+SHA1 (patch-libavdevice_sunau.h) = 2678d87f81e7b3faa42b5cc9814e373c4ad812f6
+SHA1 (patch-libavdevice_sunau__dec.c) = d2fc01e941c68ab8b6f5e0b98ee536a32cc56bdc
+SHA1 (patch-libavdevice_sunau__enc.c) = efe765b99ad6379d0237c619ac0dce41306431be
+SHA1 (patch-libavutil_macros.h) = 7d9770f018a2207d2dcb1fe057564e30be51fd42
+SHA1 (patch-libavutil_x86_asm.h) = 8f48f9e8ec08b5176bb40fc0021f3bb913dbef22
+SHA1 (patch-libavutil_x86_cpu.c) = 9c97e68fde0fcb19741e034a803d509040ea4487
diff --git a/multimedia/ffmpeg5/options.mk b/multimedia/ffmpeg5/options.mk
new file mode 100644
index 00000000000..d81892ea4ad
--- /dev/null
+++ b/multimedia/ffmpeg5/options.mk
@@ -0,0 +1,279 @@
+# $NetBSD: options.mk,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+# Global and legacy options
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.ffmpeg5
+PKG_OPTIONS_OPTIONAL_GROUPS= ssl
+PKG_OPTIONS_GROUP.ssl= gnutls mbedtls openssl
+
+PKG_SUPPORTED_OPTIONS= ass av1 bluray doc fdk-aac fontconfig freetype jack \
+ lame libvpx libwebp opencore-amr opus pulseaudio rpi rtmp \
+ speex tesseract theora vorbis x11 x264 x265 xvid
+PKG_SUGGESTED_OPTIONS= ass av1 bluray freetype fontconfig gnutls lame \
+ libvpx libwebp opus speex theora vorbis x11 x264 x265 xvid
+
+
+PLIST_VARS+= doc
+
+# Add VDPAU if it is available
+.include "../../multimedia/libvdpau/available.mk"
+.if ${VDPAU_AVAILABLE} == "yes"
+PKG_SUPPORTED_OPTIONS+= vdpau
+PKG_SUGGESTED_OPTIONS+= vdpau
+.endif
+
+# Add VAAPI if it is available
+.include "../../multimedia/libva/available.mk"
+.if ${VAAPI_AVAILABLE} == "yes"
+PKG_SUPPORTED_OPTIONS+= vaapi
+PKG_SUGGESTED_OPTIONS+= vaapi
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+# Fontconfig
+.if !empty(PKG_OPTIONS:Mfontconfig)
+CONFIGURE_ARGS+= --enable-fontconfig
+.include "../../fonts/fontconfig/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-fontconfig
+.endif
+
+# freetype option
+.if !empty(PKG_OPTIONS:Mfreetype)
+CONFIGURE_ARGS+= --enable-libfreetype
+.include "../../graphics/freetype2/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libfreetype
+.endif
+
+# ass option
+.if !empty(PKG_OPTIONS:Mass)
+CONFIGURE_ARGS+= --enable-libass
+.include "../../multimedia/libass/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libass
+.endif
+
+# av1 option
+.if !empty(PKG_OPTIONS:Mav1)
+CONFIGURE_ARGS+= --enable-libaom
+BUILDLINK_API_DEPENDS.libaom+= libaom>=1.0.0nb1
+CONFIGURE_ARGS+= --enable-libdav1d
+.include "../../multimedia/libaom/buildlink3.mk"
+.include "../../multimedia/dav1d/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libaom
+CONFIGURE_ARGS+= --disable-libdav1d
+.endif
+
+# doc option
+.if !empty(PKG_OPTIONS:Mdoc)
+PLIST.doc= yes
+USE_TOOLS+= texi2html
+CONFIGURE_ARGS+= --enable-htmlpages
+.else
+CONFIGURE_ARGS+= --disable-htmlpages
+.endif
+
+# Fraunhofer FDK AAC codec support
+.if !empty(PKG_OPTIONS:Mfdk-aac)
+RESTRICTED= ffmpeg built with fdk-aac combines GPL and GPL-incompatible code
+NO_BIN_ON_CDROM= ${RESTRICTED}
+NO_BIN_ON_FTP= ${RESTRICTED}
+CONFIGURE_ARGS+= --enable-libfdk_aac
+CONFIGURE_ARGS+= --enable-nonfree
+.include "../../audio/fdk-aac/buildlink3.mk"
+.endif
+
+# GnuTLS support
+.if !empty(PKG_OPTIONS:Mgnutls)
+CONFIGURE_ARGS+= --enable-gnutls
+.include "../../security/gnutls/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-gnutls
+.endif
+
+# mbedTLS support
+.if !empty(PKG_OPTIONS:Mmbedtls)
+CONFIGURE_ARGS+= --enable-mbedtls
+# Apache License 2.0 is incompatible with (L)GPL versions before 3
+CONFIGURE_ARGS+= --enable-version3
+ADDITIONAL_LICENSE+= AND gnu-lgpl-v3
+.include "../../security/mbedtls/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-mbedtls
+.endif
+
+# opencore-amr option
+.if !empty(PKG_OPTIONS:Mopencore-amr)
+CONFIGURE_ARGS+= --enable-libopencore-amrnb
+CONFIGURE_ARGS+= --enable-libopencore-amrwb
+# Apache License 2.0 is incompatible with (L)GPL versions before 3
+CONFIGURE_ARGS+= --enable-version3
+ADDITIONAL_LICENSE+= AND gnu-lgpl-v3
+.include "../../audio/opencore-amr/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libopencore-amrnb
+CONFIGURE_ARGS+= --disable-libopencore-amrwb
+.endif
+
+# OpenSSL support
+.if !empty(PKG_OPTIONS:Mopenssl)
+CONFIGURE_ARGS+= --enable-nonfree
+CONFIGURE_ARGS+= --enable-openssl
+.include "../../security/openssl/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-openssl
+.endif
+
+# jack option
+.if !empty(PKG_OPTIONS:Mjack)
+CONFIGURE_ARGS+= --enable-libjack
+.include "../../audio/jack/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libjack
+.endif
+
+# pulseaudio option
+.if !empty(PKG_OPTIONS:Mpulseaudio)
+CONFIGURE_ARGS+= --enable-libpulse
+.include "../../audio/pulseaudio/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libpulse
+.endif
+
+# RTMP support via librtmp
+.if !empty(PKG_OPTIONS:Mrtmp)
+CONFIGURE_ARGS+= --enable-librtmp
+.include "../../net/rtmpdump/buildlink3.mk"
+.endif
+
+# OCR filter using Tesseract
+.if !empty(PKG_OPTIONS:Mtesseract)
+CONFIGURE_ARGS+= --enable-libtesseract
+.include "../../graphics/tesseract/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libtesseract
+.endif
+
+# OGG Theora support
+.if !empty(PKG_OPTIONS:Mtheora)
+CONFIGURE_ARGS+= --enable-libtheora
+.include "../../multimedia/libtheora/buildlink3.mk"
+.endif
+
+# OGG Vorbis support
+.if !empty(PKG_OPTIONS:Mvorbis)
+CONFIGURE_ARGS+= --enable-libvorbis
+.include "../../audio/libvorbis/buildlink3.mk"
+.endif
+
+# LAME MP3 encoder
+.if !empty(PKG_OPTIONS:Mlame)
+# "lame-3.98" isn't compatible with "ffmpeg" which breaks audio encoding.
+BUILDLINK_API_DEPENDS.lame+= lame>=3.98.2nb1
+CONFIGURE_ARGS+= --enable-libmp3lame
+.include "../../audio/lame/buildlink3.mk"
+.endif
+
+# OPUS support
+.if !empty(PKG_OPTIONS:Mopus)
+CONFIGURE_ARGS+= --enable-libopus
+.include "../../audio/libopus/buildlink3.mk"
+.endif
+
+# Speex support
+.if !empty(PKG_OPTIONS:Mspeex)
+CONFIGURE_ARGS+= --enable-libspeex
+.include "../../audio/speex/buildlink3.mk"
+.endif
+
+# Raspberry Pi support
+.if !empty(PKG_OPTIONS:Mrpi)
+CONFIGURE_ARGS+= --disable-xvmc
+CONFIGURE_ARGS+= --enable-omx-rpi
+CONFIGURE_ARGS+= --enable-mmal
+SUBST_CLASSES+= vc
+SUBST_STAGE.vc= pre-configure
+SUBST_MESSAGE.vc= Fixing path to VideoCore libraries.
+SUBST_FILES.vc= configure
+SUBST_SED.vc+= -e 's;-isystem/opt/vc;-I${PREFIX};g'
+SUBST_SED.vc+= -e 's;/opt/vc;${PREFIX};g'
+.include "../../misc/raspberrypi-userland/buildlink3.mk"
+.endif
+
+# XviD support
+.if !empty(PKG_OPTIONS:Mxvid)
+CONFIGURE_ARGS+= --enable-libxvid
+.include "../../multimedia/xvidcore/buildlink3.mk"
+.endif
+
+# x264 support
+.if !empty(PKG_OPTIONS:Mx264)
+# ABI change between 20090326 and 20100201
+BUILDLINK_API_DEPENDS.x264-devel+= x264-devel>=20111207
+CONFIGURE_ARGS+= --enable-libx264
+.include "../../multimedia/x264-devel/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libx264
+.endif
+
+# x265 support
+.if !empty(PKG_OPTIONS:Mx265)
+CONFIGURE_ARGS+= --enable-libx265
+.include "../../multimedia/x265/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libx265
+.endif
+
+# VDPAU support
+.if !empty(PKG_OPTIONS:Mvdpau) && !empty(PKG_OPTIONS:Mx11)
+CONFIGURE_ARGS+= --enable-vdpau
+.include "../../multimedia/libvdpau/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-vdpau
+.endif
+
+# VAAPI support
+.if !empty(PKG_OPTIONS:Mvaapi) && !empty(PKG_OPTIONS:Mx11)
+CONFIGURE_ARGS+= --enable-vaapi
+.include "../../multimedia/libva/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-vaapi
+.endif
+
+# VPX support
+.if !empty(PKG_OPTIONS:Mlibvpx)
+CONFIGURE_ARGS+= --enable-libvpx
+.include "../../multimedia/libvpx/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libvpx
+.endif
+
+# WEBP support
+.if !empty(PKG_OPTIONS:Mlibwebp)
+CONFIGURE_ARGS+= --enable-libwebp
+.include "../../graphics/libwebp/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libwebp
+.endif
+
+# X11 screen capture support using libxcb
+.if !empty(PKG_OPTIONS:Mx11)
+CONFIGURE_ARGS+= --enable-libxcb
+CONFIGURE_ARGS+= --enable-libxcb-shape
+CONFIGURE_ARGS+= --enable-libxcb-shm
+CONFIGURE_ARGS+= --enable-libxcb-xfixes
+.include "../../x11/libxcb/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libxcb
+.endif
+
+# Bluray support
+.if !empty(PKG_OPTIONS:Mbluray)
+CONFIGURE_ARGS+= --enable-libbluray
+.include "../../multimedia/libbluray/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-libbluray
+.endif
diff --git a/multimedia/ffmpeg5/patches/patch-Makefile b/multimedia/ffmpeg5/patches/patch-Makefile
new file mode 100644
index 00000000000..d3a4980c583
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-Makefile
@@ -0,0 +1,15 @@
+$NetBSD: patch-Makefile,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Do "install -c".
+
+--- Makefile.orig 2018-04-20 10:02:55.000000000 +0000
++++ Makefile
+@@ -125,7 +125,7 @@ install-libs: install-libs-yes
+
+ install-data: $(DATA_FILES)
+ $(Q)mkdir -p "$(DATADIR)"
+- $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
++ $(INSTALL) -c -m 644 $(DATA_FILES) "$(DATADIR)"
+
+ uninstall: uninstall-data uninstall-headers uninstall-libs uninstall-pkgconfig
+
diff --git a/multimedia/ffmpeg5/patches/patch-configure b/multimedia/ffmpeg5/patches/patch-configure
new file mode 100644
index 00000000000..98a73bdcd1e
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-configure
@@ -0,0 +1,78 @@
+$NetBSD: patch-configure,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+Enable PIC and section_data_rel_ro on NetBSD, even on i386,
+to avoid text relocations.
+
+Do not use 'rsync'.
+
+--- configure.orig 2022-01-14 18:45:39.000000000 +0000
++++ configure
+@@ -2196,6 +2196,7 @@ HEADERS_LIST="
+ sys_resource_h
+ sys_select_h
+ sys_soundcard_h
++ sys_audioio_h
+ sys_time_h
+ sys_un_h
+ sys_videoio_h
+@@ -2337,7 +2338,6 @@ TOOLCHAIN_FEATURES="
+ inline_asm_labels
+ inline_asm_nonlocal_labels
+ pragma_deprecated
+- rsync_contimeout
+ symver_asm_label
+ symver_gnu_asm
+ vfp_args
+@@ -3521,6 +3521,8 @@ opengl_outdev_deps="opengl"
+ opengl_outdev_suggest="sdl2"
+ oss_indev_deps_any="sys_soundcard_h"
+ oss_outdev_deps_any="sys_soundcard_h"
++sunau_indev_deps_any="sys_audioio_h"
++sunau_outdev_deps_any="sys_audioio_h"
+ pulse_indev_deps="libpulse"
+ pulse_outdev_deps="libpulse"
+ sdl2_outdev_deps="sdl2"
+@@ -5491,6 +5493,8 @@ case $target_os in
+ ;;
+ netbsd)
+ disable symver
++ enable section_data_rel_ro
++ enable pic
+ oss_indev_extralibs="-lossaudio"
+ oss_outdev_extralibs="-lossaudio"
+ enabled gcc || check_ldflags -Wl,-zmuldefs
+@@ -5889,10 +5893,13 @@ done
+ check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
+
+ # The global variable ensures the bits appear unchanged in the object file.
+-test_cc <<EOF || die "endian test failed"
+-unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
++test_exec <<EOF || enable bigendian
++int main()
++{
++ long one = 1;
++ return !(*((char *)(&one)));
++}
+ EOF
+-od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
+
+ check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"
+
+@@ -6305,6 +6312,7 @@ check_headers malloc.h
+ check_headers mftransform.h
+ check_headers net/udplite.h
+ check_headers poll.h
++check_headers sys/audioio.h
+ check_headers sys/param.h
+ check_headers sys/resource.h
+ check_headers sys/select.h
+@@ -6776,7 +6784,6 @@ enabled makeinfo \
+ disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
+ perl -v > /dev/null 2>&1 && enable perl || disable perl
+ pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
+-rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
+ xmllint --version > /dev/null 2>&1 && enable xmllint || disable xmllint
+
+ # check V4L2 codecs available in the API
diff --git a/multimedia/ffmpeg5/patches/patch-doc_Makefile b/multimedia/ffmpeg5/patches/patch-doc_Makefile
new file mode 100644
index 00000000000..c2277f3402d
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-doc_Makefile
@@ -0,0 +1,31 @@
+$NetBSD: patch-doc_Makefile,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Make man pages and html docs versioned.
+
+--- doc/Makefile.orig 2016-02-15 02:29:37.000000000 +0000
++++ doc/Makefile
+@@ -14,8 +14,8 @@ COMPONENTS-$(CONFIG_AVFORMAT) += ffmpe
+ COMPONENTS-$(CONFIG_AVDEVICE) += ffmpeg-devices
+ COMPONENTS-$(CONFIG_AVFILTER) += ffmpeg-filters
+
+-MANPAGES1 = $(AVPROGS-yes:%=doc/%.1) $(AVPROGS-yes:%=doc/%-all.1) $(COMPONENTS-yes:%=doc/%.1)
+-MANPAGES3 = $(LIBRARIES-yes:%=doc/%.3)
++MANPAGES1 = $(AVPROGS-yes:%=doc/%5.1) $(AVPROGS-yes:%=doc/%-all5.1) $(COMPONENTS-yes:%=doc/%5.1)
++MANPAGES3 = $(LIBRARIES-yes:%=doc/%5.3)
+ MANPAGES = $(MANPAGES1) $(MANPAGES3)
+ PODPAGES = $(AVPROGS-yes:%=doc/%.pod) $(AVPROGS-yes:%=doc/%-all.pod) $(COMPONENTS-yes:%=doc/%.pod) $(LIBRARIES-yes:%=doc/%.pod)
+ HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMPONENTS-yes:%=doc/%.html) $(LIBRARIES-yes:%=doc/%.html) \
+@@ -114,10 +114,10 @@ doc/%-all.pod: doc/%.texi $(SRC_PATH)/do
+ $(Q)$(TEXIDEP)
+ $(M)perl $(SRC_PATH)/doc/texi2pod.pl -Dconfig-all=yes -Idoc $< $@
+
+-doc/%.1 doc/%.3: TAG = MAN
+-doc/%.1: doc/%.pod $(GENTEXI)
++doc/%5.1 doc/%5.3: TAG = MAN
++doc/%5.1: doc/%.pod $(GENTEXI)
+ $(M)pod2man --section=1 --center=" " --release=" " --date=" " $< > $@
+-doc/%.3: doc/%.pod $(GENTEXI)
++doc/%5.3: doc/%.pod $(GENTEXI)
+ $(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
+
+ $(DOCS) doc/doxy/html: | doc/
diff --git a/multimedia/ffmpeg5/patches/patch-doc_general__contents.texi b/multimedia/ffmpeg5/patches/patch-doc_general__contents.texi
new file mode 100644
index 00000000000..31763ec2a6c
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-doc_general__contents.texi
@@ -0,0 +1,14 @@
+$NetBSD: patch-doc_general__contents.texi,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Add Sun Audio.
+
+--- doc/general_contents.texi.orig 2021-04-10 06:55:24.000000000 +0000
++++ doc/general_contents.texi
+@@ -1419,6 +1419,7 @@ performance on systems without hardware
+ @item OSS @tab X @tab X
+ @item PulseAudio @tab X @tab X
+ @item SDL @tab @tab X
++@item Sun Audio @tab @tab X
+ @item Video4Linux2 @tab X @tab X
+ @item VfW capture @tab X @tab
+ @item X11 grabbing @tab X @tab
diff --git a/multimedia/ffmpeg5/patches/patch-doc_indevs.texi b/multimedia/ffmpeg5/patches/patch-doc_indevs.texi
new file mode 100644
index 00000000000..dda608030d9
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-doc_indevs.texi
@@ -0,0 +1,42 @@
+$NetBSD: patch-doc_indevs.texi,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+* Add sunau documentation.
+
+--- doc/indevs.texi.orig 2019-12-31 21:35:22.000000000 +0000
++++ doc/indevs.texi
+@@ -1282,6 +1282,35 @@ Set the number of channels. Default is 2
+
+ @end table
+
++@section sunau
++
++Solaris/NetBSD audio input device.
++
++The filename to provide to the input device is the device node
++representing the Sun input device, and is usually set to
++@file{/dev/audio0}.
++
++For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
++command:
++@example
++ffmpeg -f sunau -i /dev/audio0 /tmp/oss.wav
++@end example
++
++@subsection Options
++
++@table @option
++
++@item buffer_samples
++Set the size of the audio buffer in samples. Default is 32.
++
++@item sample_rate
++Set the sample rate in Hz. Default is 48000.
++
++@item channels
++Set the number of channels. Default is 2.
++
++@end table
++
+ @section video4linux2, v4l2
+
+ Video4Linux2 input video device.
diff --git a/multimedia/ffmpeg5/patches/patch-doc_outdevs.texi b/multimedia/ffmpeg5/patches/patch-doc_outdevs.texi
new file mode 100644
index 00000000000..c22777667d5
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-doc_outdevs.texi
@@ -0,0 +1,24 @@
+$NetBSD: patch-doc_outdevs.texi,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+* Add sunau documentation.
+
+--- doc/outdevs.texi.orig 2019-12-31 21:35:22.000000000 +0000
++++ doc/outdevs.texi
+@@ -393,6 +393,17 @@ ffmpeg -i INPUT -c:v rawvideo -pix_fmt y
+
+ sndio audio output device.
+
++@section sunau
++
++Solaris/NetBSD audio output device.
++
++@subsection Options
++@table @option
++
++@item buffer_samples
++Set the size of the audio buffer in samples. Default is 32.
++@end table
++
+ @section v4l2
+
+ Video4Linux2 output device.
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_Makefile b/multimedia/ffmpeg5/patches/patch-libavdevice_Makefile
new file mode 100644
index 00000000000..2fb2545a2dd
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_Makefile
@@ -0,0 +1,15 @@
+$NetBSD: patch-libavdevice_Makefile,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/Makefile.orig 2019-12-31 21:35:24.000000000 +0000
++++ libavdevice/Makefile
+@@ -43,6 +43,8 @@ OBJS-$(CONFIG_PULSE_OUTDEV)
+ OBJS-$(CONFIG_SDL2_OUTDEV) += sdl2.o
+ OBJS-$(CONFIG_SNDIO_INDEV) += sndio_dec.o sndio.o
+ OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_enc.o sndio.o
++OBJS-$(CONFIG_SUNAU_INDEV) += sunau_dec.o sunau.o
++OBJS-$(CONFIG_SUNAU_OUTDEV) += sunau_enc.o sunau.o
+ OBJS-$(CONFIG_V4L2_INDEV) += v4l2.o v4l2-common.o timefilter.o
+ OBJS-$(CONFIG_V4L2_OUTDEV) += v4l2enc.o v4l2-common.o
+ OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_alldevices.c b/multimedia/ffmpeg5/patches/patch-libavdevice_alldevices.c
new file mode 100644
index 00000000000..99786999045
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_alldevices.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-libavdevice_alldevices.c,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/alldevices.c.orig 2022-01-14 18:45:40.000000000 +0000
++++ libavdevice/alldevices.c
+@@ -48,6 +48,8 @@ extern const AVOutputFormat ff_pulse_mux
+ extern const AVOutputFormat ff_sdl2_muxer;
+ extern const AVInputFormat ff_sndio_demuxer;
+ extern const AVOutputFormat ff_sndio_muxer;
++extern const AVInputFormat ff_sunau_demuxer;
++extern const AVOutputFormat ff_sunau_muxer;
+ extern const AVInputFormat ff_v4l2_demuxer;
+ extern const AVOutputFormat ff_v4l2_muxer;
+ extern const AVInputFormat ff_vfwcap_demuxer;
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.c b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.c
new file mode 100644
index 00000000000..4ea496029fc
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.c
@@ -0,0 +1,109 @@
+$NetBSD: patch-libavdevice_sunau.c,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau.c.orig 2020-03-20 20:53:01.554485424 +0000
++++ libavdevice/sunau.c
+@@ -0,0 +1,102 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia@NetBSD.org>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <string.h>
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/log.h"
++
++#include "libavcodec/avcodec.h"
++#include "avdevice.h"
++
++#include "sunau.h"
++
++int ff_sunau_audio_open(AVFormatContext *s1, int is_output,
++ const char *audio_device)
++{
++ SunAudioData *s = s1->priv_data;
++ struct audio_info info;
++ struct audio_prinfo *prinfo;
++ int audio_fd, err;
++
++ audio_fd = avpriv_open(audio_device, is_output ? O_WRONLY : O_RDONLY);
++ if (audio_fd < 0) {
++ av_log(s1, AV_LOG_ERROR, "%s: %s\n", audio_device, av_err2str(AVERROR(errno)));
++ return AVERROR(EIO);
++ }
++
++ AUDIO_INITINFO(&info);
++
++#ifdef AUMODE_PLAY /* BSD extension */
++ info.mode = is_output ? AUMODE_PLAY : AUMODE_RECORD;
++#endif
++
++ prinfo = is_output ? &info.play : &info.record;
++
++ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ prinfo->precision = 16;
++ prinfo->sample_rate = s->sample_rate;
++ prinfo->channels = s->channels;
++
++ if ((err = ioctl(audio_fd, AUDIO_SETINFO, &info)) < 0) {
++ av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
++ goto fail;
++ }
++
++ if ((err = ioctl(audio_fd, AUDIO_GETINFO, &info)) < 0) {
++ av_log(s1, AV_LOG_ERROR, "AUDIO_GETINFO: %s\n", av_err2str(AVERROR(errno)));
++ goto fail;
++ }
++
++ s->fd = audio_fd;
++#if HAVE_BIGENDIAN
++ s->codec_id = AV_CODEC_ID_PCM_S16BE;
++#else
++ s->codec_id = AV_CODEC_ID_PCM_S16LE;
++#endif
++ s->precision = prinfo->precision;
++ s->sample_rate = prinfo->sample_rate;
++ s->channels = prinfo->channels;
++ s->blocksize = s->buffer_samples * prinfo->precision * prinfo->channels;
++
++ if ((s->buffer = malloc(s->blocksize)) == NULL) {
++ av_log(s1, AV_LOG_ERROR, "malloc: %s\n", av_err2str(AVERROR(errno)));
++ goto fail;
++ }
++
++ return 0;
++ fail:
++ close(audio_fd);
++ return AVERROR(EIO);
++}
++
++int ff_sunau_audio_close(SunAudioData *s)
++{
++ close(s->fd);
++ return 0;
++}
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.h b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.h
new file mode 100644
index 00000000000..9154b475baa
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau.h
@@ -0,0 +1,55 @@
+$NetBSD: patch-libavdevice_sunau.h,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau.h.orig 2020-03-20 20:53:01.579839153 +0000
++++ libavdevice/sunau.h
+@@ -0,0 +1,48 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia@NetBSD.org>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AVDEVICE_SUNAU_H
++#define AVDEVICE_SUNAU_H
++
++#include "libavcodec/avcodec.h"
++
++#include "libavformat/avformat.h"
++
++typedef struct SunAudioData {
++ AVClass *class;
++ int fd;
++ int buffer_samples;
++ unsigned int sample_rate;
++ unsigned int channels;
++ unsigned int precision;
++ size_t blocksize;
++ enum AVCodecID codec_id;
++ uint8_t *buffer;
++ size_t buffer_ptr;
++} SunAudioData;
++
++int ff_sunau_audio_open(AVFormatContext *s1, int is_output,
++ const char *audio_device);
++
++int ff_sunau_audio_close(SunAudioData *s);
++
++#endif /* AVDEVICE_SUNAU_H */
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__dec.c b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__dec.c
new file mode 100644
index 00000000000..39070410b58
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__dec.c
@@ -0,0 +1,145 @@
+$NetBSD: patch-libavdevice_sunau__dec.c,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau_dec.c.orig 2020-03-20 20:53:01.607986932 +0000
++++ libavdevice/sunau_dec.c
+@@ -0,0 +1,138 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia@NetBSD.org>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <stdint.h>
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <poll.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/internal.h"
++#include "libavutil/opt.h"
++#include "libavutil/time.h"
++
++#include "libavcodec/avcodec.h"
++
++#include "avdevice.h"
++#include "libavformat/internal.h"
++
++#include "sunau.h"
++
++static int audio_read_header(AVFormatContext *s1)
++{
++ SunAudioData *s = s1->priv_data;
++ AVStream *st;
++
++ st = avformat_new_stream(s1, NULL);
++ if (!st) {
++ return AVERROR(ENOMEM);
++ }
++
++ if (ff_sunau_audio_open(s1, 0, s1->url) < 0) {
++ return AVERROR(EIO);
++ }
++
++ /* take real parameters */
++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
++ st->codecpar->codec_id = s->codec_id;
++ st->codecpar->sample_rate = s->sample_rate;
++ st->codecpar->channels = s->channels;
++
++ avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
++
++ return 0;
++}
++
++static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++ SunAudioData *s = s1->priv_data;
++ struct audio_info info;
++ int ret;
++ long bdelay;
++ int64_t cur_time;
++
++ if ((ret = av_new_packet(pkt, s->blocksize)) < 0)
++ return ret;
++
++ ret = read(s->fd, pkt->data, pkt->size);
++ if (ret <= 0) {
++ av_packet_unref(pkt);
++ pkt->size = 0;
++ return ret < 0 ? AVERROR(errno) : AVERROR_EOF;
++ }
++
++ /* compute pts of the start of the packet */
++ cur_time = av_gettime();
++ bdelay = ret;
++
++#ifdef AUDIO_GETBUFINFO /* BSD extension */
++ if (ioctl(s->fd, AUDIO_GETBUFINFO, &info) == 0) {
++ bdelay += info.record.seek;
++ }
++#endif
++
++ /* subtract time represented by the number of bytes in the audio fifo */
++ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels * s->precision);
++
++ /* convert to wanted units */
++ pkt->pts = cur_time;
++
++ return 0;
++}
++
++static int audio_read_close(AVFormatContext *s1)
++{
++ SunAudioData *s = s1->priv_data;
++
++ ff_sunau_audio_close(s);
++ return 0;
++}
++
++static const AVOption options[] = {
++ { "buffer_samples", "", offsetof(SunAudioData, buffer_samples), AV_OPT_TYPE_INT, {.i64 = 32}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++ { "sample_rate", "", offsetof(SunAudioData, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1000, 192000, AV_OPT_FLAG_DECODING_PARAM },
++ { "channels", "", offsetof(SunAudioData, channels), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 12, AV_OPT_FLAG_DECODING_PARAM },
++ { NULL },
++};
++
++static const AVClass sunau_demuxer_class = {
++ .class_name = "Sun/NetBSD audio demuxer",
++ .item_name = av_default_item_name,
++ .option = options,
++ .version = LIBAVUTIL_VERSION_INT,
++ .category = AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
++};
++
++AVInputFormat ff_sunau_demuxer = {
++ .name = "sunau",
++ .long_name = NULL_IF_CONFIG_SMALL("Sun/NetBSD audio capture"),
++ .priv_data_size = sizeof(SunAudioData),
++ .read_header = audio_read_header,
++ .read_packet = audio_read_packet,
++ .read_close = audio_read_close,
++ .flags = AVFMT_NOFILE,
++ .priv_class = &sunau_demuxer_class,
++};
diff --git a/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__enc.c b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__enc.c
new file mode 100644
index 00000000000..3254cbbe81e
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavdevice_sunau__enc.c
@@ -0,0 +1,121 @@
+$NetBSD: patch-libavdevice_sunau__enc.c,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau_enc.c.orig 2020-03-20 20:53:01.636938971 +0000
++++ libavdevice/sunau_enc.c
+@@ -0,0 +1,114 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia@NetBSD.org>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/internal.h"
++
++#include "libavcodec/avcodec.h"
++
++#include "avdevice.h"
++#include "libavformat/internal.h"
++
++#include "sunau.h"
++
++static int audio_write_header(AVFormatContext *s1)
++{
++ SunAudioData *s = s1->priv_data;
++ AVStream *st;
++
++ st = s1->streams[0];
++ s->sample_rate = st->codecpar->sample_rate;
++ s->channels = st->codecpar->channels;
++ s->codec_id = st->codecpar->codec_id;
++ return ff_sunau_audio_open(s1, 1, s1->url) < 0 ? AVERROR(EIO) : 0;
++}
++
++static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++ SunAudioData *s = s1->priv_data;
++ unsigned int len, size = pkt->size;
++ uint8_t *buf = pkt->data;
++ int ret;
++
++ while (size > 0) {
++ len = FFMIN(s->blocksize - s->buffer_ptr, size);
++ memcpy(s->buffer + s->buffer_ptr, buf, len);
++ s->buffer_ptr += len;
++ if (s->buffer_ptr >= s->blocksize) {
++ for (;;) {
++ ret = write(s->fd, s->buffer, s->blocksize);
++ if (ret > 0)
++ break;
++ if (ret < 0 && (errno != EAGAIN && errno != EINTR))
++ return AVERROR(EIO);
++ }
++ s->buffer_ptr = 0;
++ }
++ buf += len;
++ size -= len;
++ }
++ return 0;
++}
++
++static int audio_write_trailer(AVFormatContext *s1)
++{
++ SunAudioData *s = s1->priv_data;
++
++ ff_sunau_audio_close(s);
++ return 0;
++}
++
++static const AVOption options[] = {
++ { "buffer_samples", "", offsetof(SunAudioData, buffer_samples), AV_OPT_TYPE_INT, {.i64 = 32}, 1, 192000, AV_OPT_FLAG_DECODING_PARAM },
++ { NULL },
++};
++
++static const AVClass sunau_muxer_class = {
++ .class_name = "Sun/NetBSD audio muxer",
++ .item_name = av_default_item_name,
++ .option = options,
++ .version = LIBAVUTIL_VERSION_INT,
++ .category = AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
++};
++
++AVOutputFormat ff_sunau_muxer = {
++ .name = "sunau",
++ .long_name = NULL_IF_CONFIG_SMALL("Sun/NetBSD audio playback"),
++ .priv_data_size = sizeof(SunAudioData),
++ /* XXX: we may need to support higher precisions in the future, but
++ right now this is what the kernel can handle natively */
++ /* XXX: find better solution with "preinit" method, needed also in
++ other formats */
++ .audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
++ .video_codec = AV_CODEC_ID_NONE,
++ .write_header = audio_write_header,
++ .write_packet = audio_write_packet,
++ .write_trailer = audio_write_trailer,
++ .flags = AVFMT_NOFILE,
++ .priv_class = &sunau_muxer_class,
++};
diff --git a/multimedia/ffmpeg5/patches/patch-libavutil_macros.h b/multimedia/ffmpeg5/patches/patch-libavutil_macros.h
new file mode 100644
index 00000000000..ee55d518492
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavutil_macros.h
@@ -0,0 +1,29 @@
+$NetBSD: patch-libavutil_macros.h,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Add required int includes on various opensource platforms.
+
+--- libavutil/macros.h.orig 2022-01-14 18:45:40.000000000 +0000
++++ libavutil/macros.h
+@@ -27,6 +27,22 @@
+
+ #include "libavutil/avconfig.h"
+
++#if defined(__cplusplus)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
++#undef _STDINT_H_
++#undef _SYS_STDINT_H_
++#undef _STDINT_H
++#undef _GCC_WRAP_STDINT_H
++#ifndef __STDC_CONSTANT_MACROS
++#define __STDC_CONSTANT_MACROS
++#endif
++#include <stdint.h>
++#endif /* FreeBSD | OpenBSD | linux */
++#if defined(__DragonFly__) || defined(__NetBSD__)
++#include <machine/int_const.h>
++#endif /* DragonFly | NetBSD */
++#endif /* __cplusplus */
++
+ #if AV_HAVE_BIGENDIAN
+ # define AV_NE(be, le) (be)
+ #else
diff --git a/multimedia/ffmpeg5/patches/patch-libavutil_x86_asm.h b/multimedia/ffmpeg5/patches/patch-libavutil_x86_asm.h
new file mode 100644
index 00000000000..ca8d14f3e3d
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavutil_x86_asm.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-libavutil_x86_asm.h,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Avoid SunOS regset.h definition for REG_SP
+
+--- libavutil/x86/asm.h.orig 2016-10-28 18:31:25.000000000 +0000
++++ libavutil/x86/asm.h
+@@ -27,6 +27,11 @@
+ typedef struct xmm_reg { uint64_t a, b; } xmm_reg;
+ typedef struct ymm_reg { uint64_t a, b, c, d; } ymm_reg;
+
++/* avoid SunOS regset.h definition for REG_SP */
++#if defined (__sun) && defined (REG_SP)
++#undef REG_SP
++#endif
++
+ #if ARCH_X86_64
+ # define FF_OPSIZE "q"
+ # define FF_REG_a "rax"
diff --git a/multimedia/ffmpeg5/patches/patch-libavutil_x86_cpu.c b/multimedia/ffmpeg5/patches/patch-libavutil_x86_cpu.c
new file mode 100644
index 00000000000..c503f31811a
--- /dev/null
+++ b/multimedia/ffmpeg5/patches/patch-libavutil_x86_cpu.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-libavutil_x86_cpu.c,v 1.1 2022/01/31 23:16:41 ryoon Exp $
+
+Make a part of the code depend on GCC >= 4.2.
+
+--- libavutil/x86/cpu.c.orig 2016-01-15 16:58:37.000000000 +0000
++++ libavutil/x86/cpu.c
+@@ -116,6 +116,7 @@ int ff_get_cpu_flags_x86(void)
+ #if HAVE_SSE
+ if (std_caps & (1 << 25))
+ rval |= AV_CPU_FLAG_SSE;
++#if !defined(__GNUC__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
+ if (std_caps & (1 << 26))
+ rval |= AV_CPU_FLAG_SSE2;
+ if (ecx & 1)
+@@ -138,6 +139,7 @@ int ff_get_cpu_flags_x86(void)
+ }
+ }
+ #endif /* HAVE_AVX */
++#endif /* gcc >= 4.2 */
+ #endif /* HAVE_SSE */
+ }
+ if (max_std_level >= 7) {