pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ffmpeg4-nbsdaudio: import ffmpeg4-4.2.2 as wip/ffmpeg4-nbsdaudio



Module Name:	pkgsrc-wip
Committed By:	Yorick Hardy <yorickhardy%gmail.com@localhost>
Pushed By:	yhardy
Date:		Sat Mar 14 20:33:22 2020 +0200
Changeset:	4d713de1fffdcb17de16dd4f514ae2059b1e31c1

Modified Files:
	Makefile
Added Files:
	ffmpeg4-nbsdaudio/ALTERNATIVES
	ffmpeg4-nbsdaudio/DESCR
	ffmpeg4-nbsdaudio/Makefile
	ffmpeg4-nbsdaudio/Makefile.common
	ffmpeg4-nbsdaudio/PLIST
	ffmpeg4-nbsdaudio/buildlink3.mk
	ffmpeg4-nbsdaudio/distinfo
	ffmpeg4-nbsdaudio/options.mk
	ffmpeg4-nbsdaudio/patches/patch-Makefile
	ffmpeg4-nbsdaudio/patches/patch-configure
	ffmpeg4-nbsdaudio/patches/patch-doc_Makefile
	ffmpeg4-nbsdaudio/patches/patch-doc_indevs.texi
	ffmpeg4-nbsdaudio/patches/patch-doc_outdevs.texi
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_Makefile
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_alldevices.c
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
	ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
	ffmpeg4-nbsdaudio/patches/patch-libavformat_sctp.c
	ffmpeg4-nbsdaudio/patches/patch-libavutil_common.h
	ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_asm.h
	ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_cpu.c

Log Message:
ffmpeg4-nbsdaudio: import ffmpeg4-4.2.2 as wip/ffmpeg4-nbsdaudio

This is a duplicate of multimedia/ffmpeg4, with additional
patches for NetBSD audio. All of the capabilities of the
NetBSD audio system are not yet available, but basic recording
and playback seems to work.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=4d713de1fffdcb17de16dd4f514ae2059b1e31c1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                           |   1 +
 ffmpeg4-nbsdaudio/ALTERNATIVES                     |   2 +
 ffmpeg4-nbsdaudio/DESCR                            |   5 +
 ffmpeg4-nbsdaudio/Makefile                         |  56 +++++
 ffmpeg4-nbsdaudio/Makefile.common                  |  92 ++++++++
 ffmpeg4-nbsdaudio/PLIST                            | 259 +++++++++++++++++++++
 ffmpeg4-nbsdaudio/buildlink3.mk                    |  63 +++++
 ffmpeg4-nbsdaudio/distinfo                         |  21 ++
 ffmpeg4-nbsdaudio/options.mk                       | 248 ++++++++++++++++++++
 ffmpeg4-nbsdaudio/patches/patch-Makefile           |  15 ++
 ffmpeg4-nbsdaudio/patches/patch-configure          |  90 +++++++
 ffmpeg4-nbsdaudio/patches/patch-doc_Makefile       |  31 +++
 ffmpeg4-nbsdaudio/patches/patch-doc_indevs.texi    |  39 ++++
 ffmpeg4-nbsdaudio/patches/patch-doc_outdevs.texi   |  17 ++
 .../patches/patch-libavdevice_Makefile             |  15 ++
 .../patches/patch-libavdevice_alldevices.c         |  15 ++
 .../patches/patch-libavdevice_nbsdaudio.c          | 136 +++++++++++
 .../patches/patch-libavdevice_nbsdaudio.h          |  51 ++++
 .../patches/patch-libavdevice_nbsdaudio__dec.c     | 157 +++++++++++++
 .../patches/patch-libavdevice_nbsdaudio__enc.c     | 120 ++++++++++
 ffmpeg4-nbsdaudio/patches/patch-libavformat_sctp.c |  17 ++
 ffmpeg4-nbsdaudio/patches/patch-libavutil_common.h |  29 +++
 .../patches/patch-libavutil_x86_asm.h              |  18 ++
 .../patches/patch-libavutil_x86_cpu.c              |  22 ++
 24 files changed, 1519 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 0a67b6e73a..b17f256bcb 100644
--- a/Makefile
+++ b/Makefile
@@ -807,6 +807,7 @@ SUBDIR+=	festvox-tp
 SUBDIR+=	feynedit
 SUBDIR+=	feynhiggs
 SUBDIR+=	ffmpeg-git
+SUBDIR+=	ffmpeg4-nbsdaudio
 SUBDIR+=	ffmpegthumbs
 SUBDIR+=	fftjet
 SUBDIR+=	fftw-mpich
diff --git a/ffmpeg4-nbsdaudio/ALTERNATIVES b/ffmpeg4-nbsdaudio/ALTERNATIVES
new file mode 100644
index 0000000000..8c2db0110e
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/ALTERNATIVES
@@ -0,0 +1,2 @@
+bin/ffmpeg @PREFIX@/bin/ffmpeg4
+bin/ffprobe @PREFIX@/bin/ffprobe4
diff --git a/ffmpeg4-nbsdaudio/DESCR b/ffmpeg4-nbsdaudio/DESCR
new file mode 100644
index 0000000000..fb761f2330
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/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 4.
diff --git a/ffmpeg4-nbsdaudio/Makefile b/ffmpeg4-nbsdaudio/Makefile
new file mode 100644
index 0000000000..cb2bb6a60c
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/Makefile
@@ -0,0 +1,56 @@
+# $NetBSD$
+
+PKGNAME=	${DISTNAME:S/ffmpeg/ffmpeg4/}
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	http://ffmpeg.mplayerhq.hu/
+COMMENT=	Decoding, encoding and streaming software (v4.x)
+
+CONFIGURE_ARGS+=	--enable-avfilter
+CONFIGURE_ARGS+=	--enable-avresample
+CONFIGURE_ARGS+=	--enable-postproc
+CONFIGURE_ARGS+=	--enable-rpath
+CONFIGURE_ARGS+=	--disable-ffplay
+
+INSTALLATION_DIRS=	lib/ffmpeg4 share/doc/ffmpeg4 share/examples/ffmpeg4
+
+.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 }
+PRINT_PLIST_AWK+=	/opencl/ { $$0 = "$${PLIST.opencl}" $$0 }
+
+TEST_TARGET=	check
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/doc/*.txt \
+		${DESTDIR}${PREFIX}/share/doc/ffmpeg4
+
+.include "options.mk"
+
+.include "../../mk/compiler.mk"
+
+# disable asm on i386 for non-gcc and gcc < 4.2
+.if ${MACHINE_ARCH} == "i386"
+.  if !empty(MACHINE_PLATFORM:MDarwin-*-i386) \
+   || !empty(MACHINE_PLATFORM:MSunOS-*-i386) \
+   || !empty(MACHINE_PLATFORM:MNetBSD-*-i386) \
+   || !empty(CC_VERSION:Mgcc-[123]*) \
+   || !empty(CC_VERSION:Mgcc-4.[01].*) \
+   || empty(CC_VERSION:Mgcc*)
+CONFIGURE_ARGS+=	--disable-asm
+.  elif !empty(CC_VERSION:Mgcc-[456].*)
+CFLAGS+=		-mstackrealign -mpreferred-stack-boundary=4
+.  endif
+.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 "../../wip/ffmpeg4-nbsdaudio/Makefile.common"
diff --git a/ffmpeg4-nbsdaudio/Makefile.common b/ffmpeg4-nbsdaudio/Makefile.common
new file mode 100644
index 0000000000..b128c54f1d
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/Makefile.common
@@ -0,0 +1,92 @@
+# $NetBSD$
+# used by multimedia/ffmpeg4/Makefile
+# used by multimedia/ffplay4/Makefile
+
+DISTNAME=	ffmpeg-4.2.2
+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}/../../wip/ffmpeg4-nbsdaudio/patches
+
+USE_LANGUAGES=		c99
+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=4
+CONFIGURE_ARGS+=	--datadir=${PREFIX}/share/ffmpeg4
+CONFIGURE_ARGS+=	--docdir=${PREFIX}/share/doc/ffmpeg4
+CONFIGURE_ARGS+=	--incdir=${PREFIX}/include/ffmpeg4
+CONFIGURE_ARGS+=	--libdir=${PREFIX}/lib/ffmpeg4
+CONFIGURE_ARGS+=	--shlibdir=${PREFIX}/lib/ffmpeg4
+LDFLAGS+=		${COMPILER_RPATH_FLAG}${PREFIX}/lib/ffmpeg4
+
+PLIST_VARS+=		opencl
+
+.if !empty(MACHINE_PLATFORM:MDarwin-1[2-9].*-*)
+CONFIGURE_ARGS+=	--enable-opencl
+PLIST.opencl=		yes
+.endif
+
+.if ${OPSYS} == "SunOS"
+USE_TOOLS+=	bash:build
+CONFIG_SHELL=	${TOOLS_PATH.bash}
+.endif
+
+CONFIGURE_ARGS+=	--enable-runtime-cpudetect
+
+# No posix_memalign() in NetBSD 4.0 and earlier
+.if !empty(MACHINE_PLATFORM:MNetBSD-[1-4].*-*)
+CONFIGURE_ARGS+=	--enable-memalign-hack
+.endif
+
+# 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 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/pthread.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/ffmpeg4-nbsdaudio/PLIST b/ffmpeg4-nbsdaudio/PLIST
new file mode 100644
index 0000000000..f0d1f7498d
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/PLIST
@@ -0,0 +1,259 @@
+@comment $NetBSD$
+bin/ffmpeg4
+bin/ffprobe4
+include/ffmpeg4/libavcodec/ac3_parser.h
+include/ffmpeg4/libavcodec/adts_parser.h
+include/ffmpeg4/libavcodec/avcodec.h
+include/ffmpeg4/libavcodec/avdct.h
+include/ffmpeg4/libavcodec/avfft.h
+include/ffmpeg4/libavcodec/d3d11va.h
+include/ffmpeg4/libavcodec/dirac.h
+include/ffmpeg4/libavcodec/dv_profile.h
+include/ffmpeg4/libavcodec/dxva2.h
+include/ffmpeg4/libavcodec/jni.h
+include/ffmpeg4/libavcodec/mediacodec.h
+include/ffmpeg4/libavcodec/qsv.h
+include/ffmpeg4/libavcodec/vaapi.h
+include/ffmpeg4/libavcodec/vdpau.h
+include/ffmpeg4/libavcodec/version.h
+include/ffmpeg4/libavcodec/videotoolbox.h
+include/ffmpeg4/libavcodec/vorbis_parser.h
+include/ffmpeg4/libavcodec/xvmc.h
+include/ffmpeg4/libavdevice/avdevice.h
+include/ffmpeg4/libavdevice/version.h
+include/ffmpeg4/libavfilter/avfilter.h
+include/ffmpeg4/libavfilter/buffersink.h
+include/ffmpeg4/libavfilter/buffersrc.h
+include/ffmpeg4/libavfilter/version.h
+include/ffmpeg4/libavformat/avformat.h
+include/ffmpeg4/libavformat/avio.h
+include/ffmpeg4/libavformat/version.h
+include/ffmpeg4/libavresample/avresample.h
+include/ffmpeg4/libavresample/version.h
+include/ffmpeg4/libavutil/adler32.h
+include/ffmpeg4/libavutil/aes.h
+include/ffmpeg4/libavutil/aes_ctr.h
+include/ffmpeg4/libavutil/attributes.h
+include/ffmpeg4/libavutil/audio_fifo.h
+include/ffmpeg4/libavutil/avassert.h
+include/ffmpeg4/libavutil/avconfig.h
+include/ffmpeg4/libavutil/avstring.h
+include/ffmpeg4/libavutil/avutil.h
+include/ffmpeg4/libavutil/base64.h
+include/ffmpeg4/libavutil/blowfish.h
+include/ffmpeg4/libavutil/bprint.h
+include/ffmpeg4/libavutil/bswap.h
+include/ffmpeg4/libavutil/buffer.h
+include/ffmpeg4/libavutil/camellia.h
+include/ffmpeg4/libavutil/cast5.h
+include/ffmpeg4/libavutil/channel_layout.h
+include/ffmpeg4/libavutil/common.h
+include/ffmpeg4/libavutil/cpu.h
+include/ffmpeg4/libavutil/crc.h
+include/ffmpeg4/libavutil/des.h
+include/ffmpeg4/libavutil/dict.h
+include/ffmpeg4/libavutil/display.h
+include/ffmpeg4/libavutil/downmix_info.h
+include/ffmpeg4/libavutil/encryption_info.h
+include/ffmpeg4/libavutil/error.h
+include/ffmpeg4/libavutil/eval.h
+include/ffmpeg4/libavutil/ffversion.h
+include/ffmpeg4/libavutil/fifo.h
+include/ffmpeg4/libavutil/file.h
+include/ffmpeg4/libavutil/frame.h
+include/ffmpeg4/libavutil/hash.h
+include/ffmpeg4/libavutil/hdr_dynamic_metadata.h
+include/ffmpeg4/libavutil/hmac.h
+include/ffmpeg4/libavutil/hwcontext.h
+include/ffmpeg4/libavutil/hwcontext_cuda.h
+include/ffmpeg4/libavutil/hwcontext_d3d11va.h
+include/ffmpeg4/libavutil/hwcontext_drm.h
+include/ffmpeg4/libavutil/hwcontext_dxva2.h
+include/ffmpeg4/libavutil/hwcontext_mediacodec.h
+include/ffmpeg4/libavutil/hwcontext_qsv.h
+include/ffmpeg4/libavutil/hwcontext_vaapi.h
+include/ffmpeg4/libavutil/hwcontext_vdpau.h
+include/ffmpeg4/libavutil/hwcontext_videotoolbox.h
+include/ffmpeg4/libavutil/imgutils.h
+include/ffmpeg4/libavutil/intfloat.h
+include/ffmpeg4/libavutil/intreadwrite.h
+include/ffmpeg4/libavutil/lfg.h
+include/ffmpeg4/libavutil/log.h
+include/ffmpeg4/libavutil/lzo.h
+include/ffmpeg4/libavutil/macros.h
+include/ffmpeg4/libavutil/mastering_display_metadata.h
+include/ffmpeg4/libavutil/mathematics.h
+include/ffmpeg4/libavutil/md5.h
+include/ffmpeg4/libavutil/mem.h
+include/ffmpeg4/libavutil/motion_vector.h
+include/ffmpeg4/libavutil/murmur3.h
+include/ffmpeg4/libavutil/opt.h
+include/ffmpeg4/libavutil/parseutils.h
+include/ffmpeg4/libavutil/pixdesc.h
+include/ffmpeg4/libavutil/pixelutils.h
+include/ffmpeg4/libavutil/pixfmt.h
+include/ffmpeg4/libavutil/random_seed.h
+include/ffmpeg4/libavutil/rational.h
+include/ffmpeg4/libavutil/rc4.h
+include/ffmpeg4/libavutil/replaygain.h
+include/ffmpeg4/libavutil/ripemd.h
+include/ffmpeg4/libavutil/samplefmt.h
+include/ffmpeg4/libavutil/sha.h
+include/ffmpeg4/libavutil/sha512.h
+include/ffmpeg4/libavutil/spherical.h
+include/ffmpeg4/libavutil/stereo3d.h
+include/ffmpeg4/libavutil/tea.h
+include/ffmpeg4/libavutil/threadmessage.h
+include/ffmpeg4/libavutil/time.h
+include/ffmpeg4/libavutil/timecode.h
+include/ffmpeg4/libavutil/timestamp.h
+include/ffmpeg4/libavutil/tree.h
+include/ffmpeg4/libavutil/twofish.h
+include/ffmpeg4/libavutil/tx.h
+include/ffmpeg4/libavutil/version.h
+include/ffmpeg4/libavutil/xtea.h
+include/ffmpeg4/libpostproc/postprocess.h
+include/ffmpeg4/libpostproc/version.h
+include/ffmpeg4/libswresample/swresample.h
+include/ffmpeg4/libswresample/version.h
+include/ffmpeg4/libswscale/swscale.h
+include/ffmpeg4/libswscale/version.h
+lib/ffmpeg4/libavcodec.a
+lib/ffmpeg4/libavcodec.so
+lib/ffmpeg4/libavcodec.so.58
+lib/ffmpeg4/libavcodec.so.58.54.100
+lib/ffmpeg4/libavdevice.a
+lib/ffmpeg4/libavdevice.so
+lib/ffmpeg4/libavdevice.so.58
+lib/ffmpeg4/libavdevice.so.58.8.100
+lib/ffmpeg4/libavfilter.a
+lib/ffmpeg4/libavfilter.so
+lib/ffmpeg4/libavfilter.so.7
+lib/ffmpeg4/libavfilter.so.7.57.100
+lib/ffmpeg4/libavformat.a
+lib/ffmpeg4/libavformat.so
+lib/ffmpeg4/libavformat.so.58
+lib/ffmpeg4/libavformat.so.58.29.100
+lib/ffmpeg4/libavresample.a
+lib/ffmpeg4/libavresample.so
+lib/ffmpeg4/libavresample.so.4
+lib/ffmpeg4/libavresample.so.4.0.0
+lib/ffmpeg4/libavutil.a
+lib/ffmpeg4/libavutil.so
+lib/ffmpeg4/libavutil.so.56
+lib/ffmpeg4/libavutil.so.56.31.100
+lib/ffmpeg4/libpostproc.a
+lib/ffmpeg4/libpostproc.so
+lib/ffmpeg4/libpostproc.so.55
+lib/ffmpeg4/libpostproc.so.55.5.100
+lib/ffmpeg4/libswresample.a
+lib/ffmpeg4/libswresample.so
+lib/ffmpeg4/libswresample.so.3
+lib/ffmpeg4/libswresample.so.3.5.100
+lib/ffmpeg4/libswscale.a
+lib/ffmpeg4/libswscale.so
+lib/ffmpeg4/libswscale.so.5
+lib/ffmpeg4/libswscale.so.5.5.100
+lib/ffmpeg4/pkgconfig/libavcodec.pc
+lib/ffmpeg4/pkgconfig/libavdevice.pc
+lib/ffmpeg4/pkgconfig/libavfilter.pc
+lib/ffmpeg4/pkgconfig/libavformat.pc
+lib/ffmpeg4/pkgconfig/libavresample.pc
+lib/ffmpeg4/pkgconfig/libavutil.pc
+lib/ffmpeg4/pkgconfig/libpostproc.pc
+lib/ffmpeg4/pkgconfig/libswresample.pc
+lib/ffmpeg4/pkgconfig/libswscale.pc
+man/man1/ffmpeg-all4.1
+man/man1/ffmpeg-bitstream-filters4.1
+man/man1/ffmpeg-codecs4.1
+man/man1/ffmpeg-devices4.1
+man/man1/ffmpeg-filters4.1
+man/man1/ffmpeg-formats4.1
+man/man1/ffmpeg-protocols4.1
+man/man1/ffmpeg-resampler4.1
+man/man1/ffmpeg-scaler4.1
+man/man1/ffmpeg-utils4.1
+man/man1/ffmpeg4.1
+man/man1/ffprobe-all4.1
+man/man1/ffprobe4.1
+man/man3/libavcodec4.3
+man/man3/libavdevice4.3
+man/man3/libavfilter4.3
+man/man3/libavformat4.3
+man/man3/libavutil4.3
+man/man3/libswresample4.3
+man/man3/libswscale4.3
+share/doc/ffmpeg4/build_system.txt
+${PLIST.doc}share/doc/ffmpeg4/developer.html
+share/doc/ffmpeg4/errno.txt
+${PLIST.doc}share/doc/ffmpeg4/faq.html
+${PLIST.doc}share/doc/ffmpeg4/fate.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-all.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-bitstream-filters.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-codecs.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-devices.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-filters.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-formats.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-protocols.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-resampler.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-scaler.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg-utils.html
+${PLIST.doc}share/doc/ffmpeg4/ffmpeg.html
+share/doc/ffmpeg4/ffmpeg.txt
+${PLIST.doc}share/doc/ffmpeg4/ffprobe-all.html
+${PLIST.doc}share/doc/ffmpeg4/ffprobe.html
+share/doc/ffmpeg4/filter_design.txt
+${PLIST.doc}share/doc/ffmpeg4/general.html
+${PLIST.doc}share/doc/ffmpeg4/git-howto.html
+share/doc/ffmpeg4/issue_tracker.txt
+share/doc/ffmpeg4/libav-merge.txt
+${PLIST.doc}share/doc/ffmpeg4/libavcodec.html
+${PLIST.doc}share/doc/ffmpeg4/libavdevice.html
+${PLIST.doc}share/doc/ffmpeg4/libavfilter.html
+${PLIST.doc}share/doc/ffmpeg4/libavformat.html
+${PLIST.doc}share/doc/ffmpeg4/libavutil.html
+${PLIST.doc}share/doc/ffmpeg4/libswresample.html
+${PLIST.doc}share/doc/ffmpeg4/libswscale.html
+share/doc/ffmpeg4/mips.txt
+share/doc/ffmpeg4/multithreading.txt
+${PLIST.doc}share/doc/ffmpeg4/nut.html
+share/doc/ffmpeg4/optimization.txt
+${PLIST.doc}share/doc/ffmpeg4/platform.html
+share/doc/ffmpeg4/rate_distortion.txt
+share/doc/ffmpeg4/snow.txt
+share/doc/ffmpeg4/swresample.txt
+share/doc/ffmpeg4/swscale.txt
+share/doc/ffmpeg4/tablegen.txt
+share/doc/ffmpeg4/undefined.txt
+share/doc/ffmpeg4/writing_filters.txt
+share/ffmpeg4/examples/Makefile
+share/ffmpeg4/examples/README
+share/ffmpeg4/examples/avio_dir_cmd.c
+share/ffmpeg4/examples/avio_reading.c
+share/ffmpeg4/examples/decode_audio.c
+share/ffmpeg4/examples/decode_video.c
+share/ffmpeg4/examples/demuxing_decoding.c
+share/ffmpeg4/examples/encode_audio.c
+share/ffmpeg4/examples/encode_video.c
+share/ffmpeg4/examples/extract_mvs.c
+share/ffmpeg4/examples/filter_audio.c
+share/ffmpeg4/examples/filtering_audio.c
+share/ffmpeg4/examples/filtering_video.c
+share/ffmpeg4/examples/http_multiclient.c
+share/ffmpeg4/examples/hw_decode.c
+share/ffmpeg4/examples/metadata.c
+share/ffmpeg4/examples/muxing.c
+share/ffmpeg4/examples/qsvdec.c
+share/ffmpeg4/examples/remuxing.c
+share/ffmpeg4/examples/resampling_audio.c
+share/ffmpeg4/examples/scaling_video.c
+share/ffmpeg4/examples/transcode_aac.c
+share/ffmpeg4/examples/transcoding.c
+share/ffmpeg4/examples/vaapi_encode.c
+share/ffmpeg4/examples/vaapi_transcode.c
+share/ffmpeg4/ffprobe.xsd
+share/ffmpeg4/libvpx-1080p.ffpreset
+share/ffmpeg4/libvpx-1080p50_60.ffpreset
+share/ffmpeg4/libvpx-360p.ffpreset
+share/ffmpeg4/libvpx-720p.ffpreset
+share/ffmpeg4/libvpx-720p50_60.ffpreset
diff --git a/ffmpeg4-nbsdaudio/buildlink3.mk b/ffmpeg4-nbsdaudio/buildlink3.mk
new file mode 100644
index 0000000000..1f9c753cbb
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/buildlink3.mk
@@ -0,0 +1,63 @@
+# $NetBSD$
+
+BUILDLINK_TREE+=	ffmpeg4
+
+.if !defined(FFMPEG4_BUILDLINK3_MK)
+FFMPEG4_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.ffmpeg4+=	ffmpeg4>=4.0
+BUILDLINK_ABI_DEPENDS.ffmpeg4+=	ffmpeg4>=4.2
+BUILDLINK_PKGSRCDIR.ffmpeg4?=	../../multimedia/ffmpeg4
+
+pkgbase := ffmpeg4
+.include "../../mk/pkg-build-options.mk"
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mav1)
+.  include "../../multimedia/libaom/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mfreetype)
+.  include "../../graphics/freetype2/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mfontconfig)
+.  include "../../fonts/fontconfig/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mtheora)
+.  include "../../multimedia/libtheora/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mxvid)
+.  include "../../multimedia/xvidcore/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mx264)
+.  include "../../multimedia/x264-devel/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mlibvpx)
+.  include "../../multimedia/libvpx/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mvaapi)
+.  include "../../multimedia/libva/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.ffmpeg4:Mvdpau)
+.  include "../../multimedia/libvdpau/buildlink3.mk"
+.endif
+
+BUILDLINK_INCDIRS.ffmpeg4+=		include/ffmpeg4
+BUILDLINK_LIBDIRS.ffmpeg4+=		lib/ffmpeg4
+BUILDLINK_FNAME_TRANSFORM.ffmpeg4+=	-e 's|lib/ffmpeg4/pkgconfig/|lib/pkgconfig/|'
+
+.include "../../archivers/bzip2/buildlink3.mk"
+.include "../../archivers/xz/buildlink3.mk"
+.include "../../devel/libgetopt/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.endif # FFMPEG4_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-ffmpeg4
diff --git a/ffmpeg4-nbsdaudio/distinfo b/ffmpeg4-nbsdaudio/distinfo
new file mode 100644
index 0000000000..4d6f3315eb
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/distinfo
@@ -0,0 +1,21 @@
+$NetBSD$
+
+SHA1 (ffmpeg-4.2.2.tar.xz) = 2557ec7d1dee31169980a8a10404129f94bd5809
+RMD160 (ffmpeg-4.2.2.tar.xz) = 2f1ff99e3a2db7a17bb6b692dd394e6f3afd803d
+SHA512 (ffmpeg-4.2.2.tar.xz) = 381cd6732fa699eb89000621cf34256920596ed1f9de3c2194dbad35fdf2165269eb7d3a147a0eb75dc18fbb6d601382b5801750e09fc63547766842f84208e3
+Size (ffmpeg-4.2.2.tar.xz) = 9094140 bytes
+SHA1 (patch-Makefile) = 2d27f218ee49179fdea14bb5c86c506dfb64dbd6
+SHA1 (patch-configure) = 63253696e75f8d12953cb938ca452e0ec36994f2
+SHA1 (patch-doc_Makefile) = 3b86307323fa565f9ad19c5bcb6ea71d323062fc
+SHA1 (patch-doc_indevs.texi) = 0ca344129aca5abe1b664b39745676d2f24af9c7
+SHA1 (patch-doc_outdevs.texi) = cc014637c2d8928596e4db6019f9c9e7f7fd5752
+SHA1 (patch-libavdevice_Makefile) = 1d1073a3c73468e4c2c00aae48acbb7f2b402146
+SHA1 (patch-libavdevice_alldevices.c) = 8662bced2511d3ab6a6f0a7b7055978a3f6d06db
+SHA1 (patch-libavdevice_nbsdaudio.c) = 4e876a88375cc4d556475e8f4f23fb01d159d18b
+SHA1 (patch-libavdevice_nbsdaudio.h) = 3fde4e36921ab1219158effb94e7e9e14c3adae7
+SHA1 (patch-libavdevice_nbsdaudio__dec.c) = 7ccc2cb5c89e7a179e59ea82f4ad6e1e51a649df
+SHA1 (patch-libavdevice_nbsdaudio__enc.c) = a9e50c61fb31422e57918bf9b9b72d63ebf4253f
+SHA1 (patch-libavformat_sctp.c) = 22bad9c7dc152aec3c60e0009899af241f495535
+SHA1 (patch-libavutil_common.h) = d0f1093bc82567807b39dde990ee347f90a082c9
+SHA1 (patch-libavutil_x86_asm.h) = 8f48f9e8ec08b5176bb40fc0021f3bb913dbef22
+SHA1 (patch-libavutil_x86_cpu.c) = 9c97e68fde0fcb19741e034a803d509040ea4487
diff --git a/ffmpeg4-nbsdaudio/options.mk b/ffmpeg4-nbsdaudio/options.mk
new file mode 100644
index 0000000000..88dcd558f9
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/options.mk
@@ -0,0 +1,248 @@
+# $NetBSD$
+
+# Global and legacy options
+
+PKG_OPTIONS_OPTIONAL_GROUPS=	ssl
+PKG_OPTIONS_GROUP.ssl=		gnutls openssl
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.ffmpeg4
+PKG_SUPPORTED_OPTIONS=	ass av1 bluray doc fdk-aac fontconfig freetype \
+			gnutls lame libvpx opencore-amr opus pulseaudio rpi \
+			rtmp tesseract theora vorbis x11 x264 x265 xvid
+PKG_SUGGESTED_OPTIONS=	lame ass av1 bluray freetype fontconfig libvpx \
+			openssl theora vorbis x11 x264 xvid
+
+PKG_OPTIONS_LEGACY_OPTS+=	xcb:x11
+
+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
+.include "../../multimedia/libaom/buildlink3.mk"
+.else
+CONFIGURE_ARGS+=	--disable-libaom
+.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=		This software may require the payment of patent royalties
+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
+
+# opencore-amr option
+.if !empty(PKG_OPTIONS:Mopencore-amr)
+CONFIGURE_ARGS+=	--enable-libopencore-amrnb
+CONFIGURE_ARGS+=	--enable-libopencore-amrwb
+# "The OpenCORE external libraries are under the Apache License
+# 2.0. That license is incompatible with the LGPL v2.1 and the GPL
+# v2, but not with version 3 of those licenses. So to combine the
+# OpenCORE libraries with FFmpeg, the license version needs to be
+# upgraded by passing --enable-version3 to configure."
+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
+
+# 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_ABI_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
+
+# 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
+
+# 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/ffmpeg4-nbsdaudio/patches/patch-Makefile b/ffmpeg4-nbsdaudio/patches/patch-Makefile
new file mode 100644
index 0000000000..4c268e6c76
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-Makefile
@@ -0,0 +1,15 @@
+$NetBSD$
+
+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/ffmpeg4-nbsdaudio/patches/patch-configure b/ffmpeg4-nbsdaudio/patches/patch-configure
new file mode 100644
index 0000000000..81dec7be09
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-configure
@@ -0,0 +1,90 @@
+$NetBSD$
+
+Enable PIC on NetBSD, even on i386 to avoid text relocations.
+Do not use 'rsync'.
+Portability fixes.
+Search for 'sys/audioio.h' to support NetBSD audio.
+
+--- configure.orig	2020-03-14 15:39:48.847772360 +0000
++++ configure
+@@ -2115,6 +2115,7 @@ HEADERS_LIST="
+     opencv2_core_core_c_h
+     OpenGL_gl3_h
+     poll_h
++    sys_audioio_h
+     sys_param_h
+     sys_resource_h
+     sys_select_h
+@@ -2257,7 +2258,6 @@ TOOLCHAIN_FEATURES="
+     inline_asm_labels
+     inline_asm_nonlocal_labels
+     pragma_deprecated
+-    rsync_contimeout
+     symver_asm_label
+     symver_gnu_asm
+     vfp_args
+@@ -3331,6 +3331,8 @@ kmsgrab_indev_deps="libdrm"
+ lavfi_indev_deps="avfilter"
+ libcdio_indev_deps="libcdio"
+ libdc1394_indev_deps="libdc1394"
++nbsdaudio_indev_deps_any="sys_audioio_h"
++nbsdaudio_outdev_deps_any="sys_audioio_h"
+ openal_indev_deps="openal"
+ opengl_outdev_deps="opengl"
+ opengl_outdev_suggest="sdl2"
+@@ -4950,9 +4952,9 @@ elif enabled mips; then
+                 disable mipsdsp
+                 disable mipsdspr2
+                 # When gcc version less than 5.3.0, add -fno-expensive-optimizations flag.
+-                if [ $cc == gcc ]; then
++                if [ $cc = gcc ]; then
+                     gcc_version=$(gcc -dumpversion)
+-                    if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV | head -n 1)" == "$gcc_version" ]; then
++                    if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV | head -n 1)" = "$gcc_version" ]; then
+                         expensive_optimization_flag=""
+                     else
+                         expensive_optimization_flag="-fno-expensive-optimizations"
+@@ -5247,6 +5249,7 @@ case $target_os in
+         ;;
+     netbsd)
+         disable symver
++        enable pic
+         oss_indev_extralibs="-lossaudio"
+         oss_outdev_extralibs="-lossaudio"
+         enabled gcc || check_ldflags -Wl,-zmuldefs
+@@ -5639,10 +5642,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 } }"
+ 
+@@ -6427,7 +6433,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
+ 
+ # check V4L2 codecs available in the API
+ check_headers linux/fb.h
+@@ -6461,6 +6466,10 @@ check_headers "dev/bktr/ioctl_meteor.h d
+     check_headers "dev/video/meteor/ioctl_meteor.h dev/video/bktr/ioctl_bt848.h" ||
+     check_headers "dev/ic/bt8xx.h"
+ 
++if check_struct sys/audioio.h audio_info_t blocksize; then
++    enable_sanitized sys/audioio.h
++fi
++
+ if check_struct sys/soundcard.h audio_buf_info bytes; then
+     enable_sanitized sys/soundcard.h
+ else
diff --git a/ffmpeg4-nbsdaudio/patches/patch-doc_Makefile b/ffmpeg4-nbsdaudio/patches/patch-doc_Makefile
new file mode 100644
index 0000000000..17158e024b
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-doc_Makefile
@@ -0,0 +1,31 @@
+$NetBSD$
+
+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/%4.1)    $(AVPROGS-yes:%=doc/%-all4.1)    $(COMPONENTS-yes:%=doc/%4.1)
++MANPAGES3   = $(LIBRARIES-yes:%=doc/%4.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/%4.1 doc/%4.3: TAG = MAN
++doc/%4.1: doc/%.pod $(GENTEXI)
+ 	$(M)pod2man --section=1 --center=" " --release=" " --date=" " $< > $@
+-doc/%.3: doc/%.pod $(GENTEXI)
++doc/%4.3: doc/%.pod $(GENTEXI)
+ 	$(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
+ 
+ $(DOCS) doc/doxy/html: | doc/
diff --git a/ffmpeg4-nbsdaudio/patches/patch-doc_indevs.texi b/ffmpeg4-nbsdaudio/patches/patch-doc_indevs.texi
new file mode 100644
index 0000000000..d6c7ff42e3
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-doc_indevs.texi
@@ -0,0 +1,39 @@
+$NetBSD$
+
+Add documentation for NetBSD audio.
+
+--- doc/indevs.texi.orig	2019-12-31 21:35:22.000000000 +0000
++++ doc/indevs.texi
+@@ -1083,6 +1083,32 @@ Set the video size given as a string suc
+ Default is @code{qvga}.
+ @end table
+ 
++@section nbsdaudio
++
++NetBSD audio input device.
++
++The filename to provide to the input device is the device node
++representing the audio input device, and is usually set to
++@file{/dev/audio}.
++
++For example to grab from @file{/dev/audio} using @command{ffmpeg} use the
++command:
++@example
++ffmpeg -f nbsdaudio -i /dev/audio /tmp/netbsd.wav
++@end example
++
++@subsection Options
++
++@table @option
++
++@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 openal
+ 
+ The OpenAL input device provides audio capture on all systems with a
diff --git a/ffmpeg4-nbsdaudio/patches/patch-doc_outdevs.texi b/ffmpeg4-nbsdaudio/patches/patch-doc_outdevs.texi
new file mode 100644
index 0000000000..f93c20093a
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-doc_outdevs.texi
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Add documentation for NetBSD audio.
+
+--- doc/outdevs.texi.orig	2019-12-31 21:35:22.000000000 +0000
++++ doc/outdevs.texi
+@@ -220,6 +220,10 @@ ffmpeg -re -i INPUT -c:v rawvideo -pix_f
+ 
+ See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
+ 
++@section nbsdaudio
++
++NetBSD audio output.
++
+ @section opengl
+ OpenGL output device.
+ 
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_Makefile b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_Makefile
new file mode 100644
index 0000000000..ade2959d1f
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_Makefile
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/Makefile.orig	2019-12-31 21:35:24.000000000 +0000
++++ libavdevice/Makefile
+@@ -32,6 +32,8 @@ OBJS-$(CONFIG_IEC61883_INDEV)           
+ OBJS-$(CONFIG_JACK_INDEV)                += jack.o timefilter.o
+ OBJS-$(CONFIG_KMSGRAB_INDEV)             += kmsgrab.o
+ OBJS-$(CONFIG_LAVFI_INDEV)               += lavfi.o
++OBJS-$(CONFIG_NBSDAUDIO_INDEV)           += nbsdaudio_dec.o nbsdaudio.o
++OBJS-$(CONFIG_NBSDAUDIO_OUTDEV)          += nbsdaudio_enc.o nbsdaudio.o
+ OBJS-$(CONFIG_OPENAL_INDEV)              += openal-dec.o
+ OBJS-$(CONFIG_OPENGL_OUTDEV)             += opengl_enc.o
+ OBJS-$(CONFIG_OSS_INDEV)                 += oss_dec.o oss.o
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_alldevices.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_alldevices.c
new file mode 100644
index 0000000000..9b8d82266b
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_alldevices.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/alldevices.c.orig	2019-12-31 21:35:24.000000000 +0000
++++ libavdevice/alldevices.c
+@@ -40,6 +40,8 @@ extern AVInputFormat  ff_iec61883_demuxe
+ extern AVInputFormat  ff_jack_demuxer;
+ extern AVInputFormat  ff_kmsgrab_demuxer;
+ extern AVInputFormat  ff_lavfi_demuxer;
++extern AVInputFormat  ff_nbsdaudio_demuxer;
++extern AVOutputFormat ff_nbsdaudio_muxer;
+ extern AVInputFormat  ff_openal_demuxer;
+ extern AVOutputFormat ff_opengl_muxer;
+ extern AVInputFormat  ff_oss_demuxer;
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
new file mode 100644
index 0000000000..8464edc035
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
@@ -0,0 +1,136 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/nbsdaudio.c.orig	2020-03-14 15:39:35.169889227 +0000
++++ libavdevice/nbsdaudio.c
+@@ -0,0 +1,129 @@
++/*
++ * NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ *
++ * 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>
++
++#if HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#include <fcntl.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/log.h"
++
++#include "libavcodec/avcodec.h"
++#include "avdevice.h"
++
++#include "nbsdaudio.h"
++
++int ff_nbsdaudio_audio_open(AVFormatContext *s1, int is_output,
++                          const char *audio_device)
++{
++    NBSDAudioData *s = s1->priv_data;
++    audio_info_t info;
++    struct audio_prinfo *prinfo;
++    int audio_fd, err;
++
++    if (is_output)
++        audio_fd = avpriv_open(audio_device, O_WRONLY);
++    else
++        audio_fd = avpriv_open(audio_device, O_RDONLY);
++    if (audio_fd < 0) {
++        av_log(s1, AV_LOG_ERROR, "%s: %s\n", audio_device, av_err2str(AVERROR(errno)));
++        return AVERROR(EIO);
++    }
++
++#if 0
++    /* non blocking mode */
++    if (!is_output) {
++        if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
++            av_log(s1, AV_LOG_WARNING, "%s: Could not enable non block mode (%s)\n", audio_device, av_err2str(AVERROR(errno)));
++        }
++    }
++#endif
++
++    s->frame_size = NBSDAUDIO_BLOCK_SIZE;
++
++#define CHECK_IOCTL_ERROR(event)                                              \
++    if (err < 0) {                                                            \
++        av_log(s1, AV_LOG_ERROR, #event ": %s\n", av_err2str(AVERROR(errno)));\
++        goto fail;                                                            \
++    }
++
++    AUDIO_INITINFO(&info);
++
++    if (is_output) {
++        prinfo = &(info.play);
++        info.mode = AUMODE_PLAY;
++    } else {
++        prinfo = &(info.record);
++        info.mode = AUMODE_RECORD;
++    }
++
++    prinfo->encoding = AUDIO_ENCODING_SLINEAR;
++    prinfo->sample_rate = s->sample_rate;
++    prinfo->channels = s->channels;
++    prinfo->precision = 16;
++    prinfo->pause = 0;
++    
++    err=ioctl(audio_fd, AUDIO_SETINFO, &info);
++    CHECK_IOCTL_ERROR(AUDIO_SETINFO)
++
++    err=ioctl(audio_fd, AUDIO_GETINFO, &info);
++    CHECK_IOCTL_ERROR(AUDIO_GETINFO)
++
++    s->fd = audio_fd;
++    if (is_output) {
++        s->sample_rate = prinfo->sample_rate;
++        s->channels = prinfo->channels;
++    } else {
++        s->sample_rate = prinfo->sample_rate;
++        s->channels = prinfo->channels;
++    }
++
++    switch(prinfo->encoding) {
++    case AUDIO_ENCODING_SLINEAR_LE:
++        s->codec_id = AV_CODEC_ID_PCM_S16LE;
++        break;
++    case AUDIO_ENCODING_SLINEAR_BE:
++        s->codec_id = AV_CODEC_ID_PCM_S16BE;
++        break;
++    default:
++        av_log(s1, AV_LOG_ERROR, "Soundcard does not support signed 16 bit sample format\n");
++        close(audio_fd);
++        return AVERROR(EIO);
++    }
++
++    return 0;
++ fail:
++    close(audio_fd);
++    return AVERROR(EIO);
++#undef CHECK_IOCTL_ERROR
++}
++
++int ff_nbsdaudio_audio_close(NBSDAudioData *s)
++{
++    close(s->fd);
++    return 0;
++}
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
new file mode 100644
index 0000000000..e95a123077
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
@@ -0,0 +1,51 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/nbsdaudio.h.orig	2020-03-14 15:39:35.182631007 +0000
++++ libavdevice/nbsdaudio.h
+@@ -0,0 +1,44 @@
++/*
++ * 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_NBSDAUDIO_H
++#define AVDEVICE_NBSDAUDIO_H
++
++#include "libavcodec/avcodec.h"
++
++#include "libavformat/avformat.h"
++
++#define NBSDAUDIO_BLOCK_SIZE 4096
++
++typedef struct NBSDAudioData {
++    AVClass *class;
++    int fd;
++    int sample_rate;
++    int channels;
++    int frame_size; /* in bytes ! */
++    enum AVCodecID codec_id;
++    uint8_t buffer[NBSDAUDIO_BLOCK_SIZE];
++    int buffer_ptr;
++} NBSDAudioData;
++
++int ff_nbsdaudio_audio_open(AVFormatContext *s1, int is_output,
++                            const char *audio_device);
++
++int ff_nbsdaudio_audio_close(NBSDAudioData *s);
++
++#endif /* AVDEVICE_NBSDAUDIO_H */
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
new file mode 100644
index 0000000000..38e78553e9
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
@@ -0,0 +1,157 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/nbsdaudio_dec.c.orig	2020-03-14 15:39:35.195802010 +0000
++++ libavdevice/nbsdaudio_dec.c
+@@ -0,0 +1,150 @@
++/*
++ * Sun and NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ *
++ * 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>
++
++#if HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#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 "nbsdaudio.h"
++
++static int audio_read_header(AVFormatContext *s1)
++{
++    NBSDAudioData *s = s1->priv_data;
++    AVStream *st;
++    int ret;
++    uint8_t b[4]; /* enough for 1 frame: 2 channels * 16 bit */
++
++    st = avformat_new_stream(s1, NULL);
++    if (!st) {
++        return AVERROR(ENOMEM);
++    }
++
++    ret = ff_nbsdaudio_audio_open(s1, 0, s1->url);
++    if (ret < 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 */
++
++    /* start recording */
++    read(s->fd, b, 4);
++
++    return 0;
++}
++
++static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++    NBSDAudioData *s = s1->priv_data;
++    audio_info_t info;
++    int ret, bdelay;
++    int64_t cur_time;
++    struct pollfd pfd;
++
++    if ((ret=av_new_packet(pkt, s->frame_size)) < 0)
++        return ret;
++
++    pfd.fd = s->fd;
++    pfd.events = POLLRDNORM;
++    if ((poll(&pfd, 1, 0) != 1) || (pfd.revents != POLLRDNORM)) {
++        av_packet_unref(pkt);
++        pkt->size = 0;
++        return AVERROR(EAGAIN);
++    }
++
++    ret = read(s->fd, pkt->data, pkt->size);
++    if (ret <= 0){
++        av_packet_unref(pkt);
++        pkt->size = 0;
++        if (ret<0)  return AVERROR(errno);
++        else        return AVERROR_EOF;
++    }
++    pkt->size = ret;
++
++    /* compute pts of the start of the packet */
++    cur_time = av_gettime();
++    bdelay = ret;
++    if (ioctl(s->fd, AUDIO_GETBUFINFO, &info) == 0) {
++        bdelay += info.record.seek;
++    }
++    /* subtract time represented by the number of bytes in the audio fifo */
++    cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
++
++    /* convert to wanted units */
++    pkt->pts = cur_time;
++ 
++    return 0;
++}
++
++static int audio_read_close(AVFormatContext *s1)
++{
++    NBSDAudioData *s = s1->priv_data;
++
++    ff_nbsdaudio_audio_close(s);
++    return 0;
++}
++
++static const AVOption options[] = {
++    { "sample_rate", "", offsetof(NBSDAudioData, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++    { "channels",    "", offsetof(NBSDAudioData, channels),    AV_OPT_TYPE_INT, {.i64 = 2},     1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++    { NULL },
++};
++
++static const AVClass nbsdaudio_demuxer_class = {
++    .class_name     = "Sun audio demuxer",
++    .item_name      = av_default_item_name,
++    .option         = options,
++    .version        = LIBAVUTIL_VERSION_INT,
++    .category       = AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
++};
++
++AVInputFormat ff_nbsdaudio_demuxer = {
++    .name           = "nbsdaudio",
++    .long_name      = NULL_IF_CONFIG_SMALL("Sun audio capture"),
++    .priv_data_size = sizeof(NBSDAudioData),
++    .read_header    = audio_read_header,
++    .read_packet    = audio_read_packet,
++    .read_close     = audio_read_close,
++    .flags          = AVFMT_NOFILE,
++    .priv_class     = &nbsdaudio_demuxer_class,
++};
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
new file mode 100644
index 0000000000..460889f906
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
@@ -0,0 +1,120 @@
+$NetBSD$
+
+Add support for NetBSD audio.
+
+--- libavdevice/nbsdaudio_enc.c.orig	2020-03-14 15:39:35.204240213 +0000
++++ libavdevice/nbsdaudio_enc.c
+@@ -0,0 +1,113 @@
++/*
++ * Sun and NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ *
++ * 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"
++
++#if HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#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 "nbsdaudio.h"
++
++static int audio_write_header(AVFormatContext *s1)
++{
++    NBSDAudioData *s = s1->priv_data;
++    AVStream *st;
++    int ret;
++
++    st = s1->streams[0];
++    s->sample_rate = st->codecpar->sample_rate;
++    s->channels = st->codecpar->channels;
++    ret = ff_nbsdaudio_audio_open(s1, 1, s1->url);
++    if (ret < 0) {
++        return AVERROR(EIO);
++    } else {
++        return 0;
++    }
++}
++
++static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++    NBSDAudioData *s = s1->priv_data;
++    int len, ret;
++    int size= pkt->size;
++    uint8_t *buf= pkt->data;
++
++    while (size > 0) {
++        len = FFMIN(NBSDAUDIO_BLOCK_SIZE - s->buffer_ptr, size);
++        memcpy(s->buffer + s->buffer_ptr, buf, len);
++        s->buffer_ptr += len;
++        if (s->buffer_ptr >= NBSDAUDIO_BLOCK_SIZE) {
++            for(;;) {
++                ret = write(s->fd, s->buffer, NBSDAUDIO_BLOCK_SIZE);
++                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)
++{
++    NBSDAudioData *s = s1->priv_data;
++
++    ff_nbsdaudio_audio_close(s);
++    return 0;
++}
++
++static const AVClass nbsdaudio_muxer_class = {
++    .class_name     = "NetBSD audio muxer",
++    .item_name      = av_default_item_name,
++    .version        = LIBAVUTIL_VERSION_INT,
++    .category       = AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
++};
++
++AVOutputFormat ff_nbsdaudio_muxer = {
++    .name           = "nbsdaudio",
++    .long_name      = NULL_IF_CONFIG_SMALL("NetBSD audio playback"),
++    .priv_data_size = sizeof(NBSDAudioData),
++    /* XXX: we make the assumption that the soundcard accepts this format */
++    /* 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     = &nbsdaudio_muxer_class,
++};
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavformat_sctp.c b/ffmpeg4-nbsdaudio/patches/patch-libavformat_sctp.c
new file mode 100644
index 0000000000..462b15a3f0
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavformat_sctp.c
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Fix for NetBSD 7.
+
+--- libavformat/sctp.c.orig	2018-02-12 19:57:53.000000000 +0000
++++ libavformat/sctp.c
+@@ -40,6 +40,10 @@
+ #include <netinet/in.h>
+ #include <netinet/sctp.h>
+ 
++#ifndef IPPROTO_SCTP
++#define IPPROTO_SCTP 132
++#endif
++
+ #include "config.h"
+ 
+ #if HAVE_POLL_H
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavutil_common.h b/ffmpeg4-nbsdaudio/patches/patch-libavutil_common.h
new file mode 100644
index 0000000000..86516d1b9b
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavutil_common.h
@@ -0,0 +1,29 @@
+$NetBSD$
+
+Add required int includes on various opensource platforms.
+
+--- libavutil/common.h.orig	2016-01-15 16:58:36.000000000 +0000
++++ libavutil/common.h
+@@ -43,6 +43,22 @@
+ #include "version.h"
+ #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/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_asm.h b/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_asm.h
new file mode 100644
index 0000000000..d9c4de8fec
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_asm.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+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/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_cpu.c b/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_cpu.c
new file mode 100644
index 0000000000..f38688cdc8
--- /dev/null
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavutil_x86_cpu.c
@@ -0,0 +1,22 @@
+$NetBSD$
+
+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) {


Home | Main Index | Thread Index | Old Index