Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
enable webm (libvorbis, libvpx) in ffmpeg (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jan 17, 2020
1 parent bc270bb commit 9b427f4
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mingw-w64-ffmpeg/PKGBUILD
Expand Up @@ -14,6 +14,8 @@ license=('GPL')
options=('staticlibs' 'strip')
depends=("${MINGW_PACKAGE_PREFIX}-bzip2"
"${MINGW_PACKAGE_PREFIX}-lame"
"${MINGW_PACKAGE_PREFIX}-libvorbis"
"${MINGW_PACKAGE_PREFIX}-libvpx"
"${MINGW_PACKAGE_PREFIX}-x264"
"${MINGW_PACKAGE_PREFIX}-xvidcore"
"${MINGW_PACKAGE_PREFIX}-zlib")
Expand Down Expand Up @@ -53,11 +55,14 @@ build() {
--enable-libmp3lame \
--enable-libx264 \
--enable-libxvid \
--enable-libvorbis \
--enable-libvpx \
--enable-hardcoded-tables \
--enable-version3 \
--enable-zlib \
--disable-lzma \
--disable-doc
--disable-doc \
--extra-libs="$(${PKG_CONFIG:-pkgconfig} --libs-only-l --static vorbis)"

make
}
Expand Down
168 changes: 168 additions & 0 deletions mingw-w64-libvpx/0001-enable-shared-on.mingw.patch
@@ -0,0 +1,168 @@
diff -aur libvpx-1.6.0-orig/build/make/configure.sh libvpx-1.6.0/build/make/configure.sh
--- libvpx-1.6.0-orig/build/make/configure.sh 2016-07-21 04:15:41.000000000 +0300
+++ libvpx-1.6.0/build/make/configure.sh 2016-07-28 18:34:25.287546800 +0300
@@ -647,7 +647,10 @@
--libdir=*)
libdir="${optval}"
;;
- --libc|--as|--prefix|--libdir)
+ --bindir=*)
+ bindir="${optval}"
+ ;;
+ --libc|--as|--prefix|--libdir|--bindir)
die "Option ${opt} requires argument"
;;
--help|-h)
@@ -618,9 +621,14 @@
prefix="${prefix%/}"
libdir="${libdir:-${prefix}/lib}"
libdir="${libdir%/}"
+ bindir="${bindir:-${prefix}/bin}"
+ bindir="${bindir%/}"
if [ "${libdir#${prefix}}" = "${libdir}" ]; then
die "Libdir ${libdir} must be a subdirectory of ${prefix}"
fi
+ if [ "${bindir#${prefix}}" = "${bindir}" ]; then
+ die "Bindir ${bindir} must be a subdirectory of ${prefix}"
+ fi
}

post_process_cmdline() {
diff -aur libvpx-1.6.0-orig/build/make/Makefile libvpx-1.6.0/build/make/Makefile
--- libvpx-1.6.0-orig/build/make/Makefile 2016-07-21 04:15:41.000000000 +0300
+++ libvpx-1.6.0/build/make/Makefile 2016-07-28 18:34:25.287546800 +0300
@@ -300,6 +300,20 @@
$$(filter %.o,$$^) $$(extralibs)
endef

+define dll_gnu_template
+# Not using a pattern rule here because we don't want to generate empty
+# archives when they are listed as a dependency in files not responsible
+# for creating them.
+#
+# This needs further abstraction for dealing with non-GNU linkers.
+$(1):
+ $(if $(quiet),@echo " [LD] $$@")
+ $(qexec)$$(LD) -shared $$(LDFLAGS) \
+ -Wl,--no-undefined \
+ -o $$@ \
+ -Wl,--out-implib=$$(subst $(2),.dll.a,$(1)) $$(filter %.o,$$^) $$(extralibs)
+endef
+
define dl_template
# Not using a pattern rule here because we don't want to generate empty
# archives when they are listed as a dependency in files not responsible
@@ -383,6 +397,7 @@
$(foreach lib,$(filter %so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
$(foreach lib,$(filter %$(SO_VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib))))
$(foreach lib,$(filter %$(SO_VERSION_MAJOR).dll,$(LIBS)),$(eval $(call dll_template,$(lib))))
+$(foreach lib,$(filter %-$(VERSION_MAJOR).dll,$(LIBS)),$(eval $(call dll_gnu_template,$(lib),-$(VERSION_MAJOR).dll)))

INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist)
Only in libvpx-1.6.0/build/make: Makefile.orig
diff -aur libvpx-1.6.0-orig/configure libvpx-1.6.0/configure
--- libvpx-1.6.0-orig/configure 2016-07-21 04:15:41.000000000 +0300
+++ libvpx-1.6.0/configure 2016-07-28 18:37:36.879364800 +0300
@@ -473,6 +473,7 @@
DIST_DIR?=\$(DESTDIR)${prefix}
endif
LIBSUBDIR=${libdir##${prefix}/}
+BINSUBDIR=${bindir##${prefix}/}

VERSION_STRING=${VERSION_STRING}

@@ -510,9 +511,13 @@
;;
*)
if enabled gnu; then
- echo "--enable-shared is only supported on ELF; assuming this is OK"
+ echo "--enable-shared is only supported on ELF and PE; assuming this is OK"
+ elif enabled win32; then
+ echo "--enable-shared is only supported on ELF and PE; assuming this is OK"
+ elif enabled win64; then
+ echo "--enable-shared is only supported on ELF and PE; assuming this is OK"
else
- die "--enable-shared only supported on ELF, OS/2, and Darwin for now"
+ die "--enable-shared only supported on ELF, OS/2, Darwin and PE for now"
fi
;;
esac
diff -aur libvpx-1.6.0-orig/examples.mk libvpx-1.6.0/examples.mk
--- libvpx-1.6.0-orig/examples.mk 2016-07-21 04:15:41.000000000 +0300
+++ libvpx-1.6.0/examples.mk 2016-07-28 18:34:25.303172800 +0300
@@ -302,9 +302,13 @@
ifneq ($(filter os2%,$(TGT_OS)),)
SHARED_LIB_SUF=_dll.a
else
+ifneq ($(filter win%,$(TGT_OS)),)
+SHARED_LIB_SUF=.dll.a
+else
SHARED_LIB_SUF=.so
endif
endif
+endif
CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
$(foreach bin,$(BINS-yes),\
$(eval $(bin):$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF))\
diff -aur libvpx-1.6.0-orig/libs.mk libvpx-1.6.0/libs.mk
--- libvpx-1.6.0-orig/libs.mk 2016-07-21 04:15:41.000000000 +0300
+++ libvpx-1.6.0/libs.mk 2016-07-28 18:34:25.303172800 +0300
@@ -130,6 +130,7 @@
INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
INSTALL_MAPS += $(LIBSUBDIR)/% %
+INSTALL_MAPS += $(BINSUBDIR)/% %
INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
ifeq ($(CONFIG_MSVS),yes)
INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
@@ -252,6 +253,13 @@
LIBVPX_SO_SYMLINKS :=
LIBVPX_SO_IMPLIB := libvpx_dll.a
else
+ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
+LIBVPX_SO := libvpx-$(VERSION_MAJOR).dll
+SHARED_LIB_SUF := .dll.a
+EXPORT_FILE :=
+LIBVPX_SO_SYMLINKS :=
+LIBVPX_SO_IMPLIB := libvpx.dll.a
+else
LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
SHARED_LIB_SUF := .so
EXPORT_FILE := libvpx.ver
@@ -261,13 +269,14 @@
endif
endif
endif
+endif

LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\
$(notdir $(LIBVPX_SO_SYMLINKS)) \
$(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB))
$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
-$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR)
+$(BUILD_PFX)$(LIBVPX_SO): SONAME = $(LIBVPX_SO)
$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)

libvpx.ver: $(call enabled,CODEC_EXPORTS)
@@ -295,6 +304,10 @@
$(qexec)emximp -o $@ $<
CLEAN-OBJS += libvpx_dll.a

+libvpx.dll.a: $(LIBVPX_SO)
+ @echo " [IMPLIB] $@"
+CLEAN-OBJS += libvpx.dll.a
+
define libvpx_symlink_template
$(1): $(2)
@echo " [LN] $(2) $$@"
@@ -311,7 +324,7 @@


INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
-INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
+INSTALL-LIBS-$(CONFIG_SHARED) += $(BINSUBDIR)/$(LIBVPX_SO)
INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB))


36 changes: 36 additions & 0 deletions mingw-w64-libvpx/0002-no-pthreads.mingw.patch
@@ -0,0 +1,36 @@
diff -Naur libvpx-1.8.0.orig/configure libvpx-1.8.0/configure
--- libvpx-1.8.0.orig/configure 2019-04-04 20:21:43.685074600 -0400
+++ libvpx-1.8.0/configure 2019-04-04 20:23:43.924370800 -0400
@@ -265,7 +265,6 @@
HAVE_LIST="
${ARCH_EXT_LIST}
vpx_ports
- pthread_h
unistd_h
"
EXPERIMENT_LIST="
@@ -582,11 +581,6 @@

# Use both check_header and check_lib here, since check_lib
# could be a stub that always returns true.
- check_header pthread.h && check_lib -lpthread <<EOF || disable_feature pthread_h
-#include <pthread.h>
-#include <stddef.h>
-int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
-EOF
check_header unistd.h # for sysconf(3) and friends.

check_header vpx/vpx_integer.h -I${source_path} && enable_feature vpx_ports
diff -Naur libvpx-1.8.0.orig/vp8/common/generic/systemdependent.c libvpx-1.8.0/vp8/common/generic/systemdependent.c
--- libvpx-1.8.0.orig/vp8/common/generic/systemdependent.c 2019-04-04 20:21:43.903881700 -0400
+++ libvpx-1.8.0/vp8/common/generic/systemdependent.c 2019-04-04 20:24:40.116494200 -0400
@@ -23,7 +23,8 @@
#if CONFIG_MULTITHREAD
#if HAVE_UNISTD_H && !defined(__OS2__)
#include <unistd.h>
-#elif defined(_WIN32)
+#endif
+#if defined(_WIN32)
#include <windows.h>
typedef void(WINAPI *PGNSI)(LPSYSTEM_INFO);
#elif defined(__OS2__)
23 changes: 23 additions & 0 deletions mingw-w64-libvpx/0003-cross-with-native-binutils.mingw.patch
@@ -0,0 +1,23 @@
--- libvpx-1.6.1/build/make/configure.sh.orig 2017-04-18 07:55:35.521235500 -0400
+++ libvpx-1.6.1/build/make/configure.sh 2017-04-18 08:03:57.773345200 -0400
@@ -636,13 +636,13 @@ post_process_cmdline() {
}

setup_gnu_toolchain() {
- CC=${CC:-${CROSS}gcc}
- CXX=${CXX:-${CROSS}g++}
- AR=${AR:-${CROSS}ar}
- LD=${LD:-${CROSS}${link_with_cc:-ld}}
- AS=${AS:-${CROSS}as}
- STRIP=${STRIP:-${CROSS}strip}
- NM=${NM:-${CROSS}nm}
+ CC=${CC:-gcc}
+ CXX=${CXX:-g++}
+ AR=${AR:-ar}
+ LD=${LD:-${link_with_cc:-ld}}
+ AS=${AS:-as}
+ STRIP=${STRIP:-strip}
+ NM=${NM:-nm}
AS_SFX=.S
EXE_SFX=
}
11 changes: 11 additions & 0 deletions mingw-w64-libvpx/0005-fix-exports.mingw.patch
@@ -0,0 +1,11 @@
diff -Naur libvpx-1.4.0-orig/vpx/exports_enc libvpx-1.4.0/vpx/exports_enc
--- libvpx-1.4.0-orig/vpx/exports_enc 2015-04-03 21:49:19.000000000 +0300
+++ libvpx-1.4.0/vpx/exports_enc 2015-04-07 09:41:36.904200000 +0300
@@ -2,6 +2,7 @@
text vpx_codec_enc_config_set
text vpx_codec_enc_init_multi_ver
text vpx_codec_enc_init_ver
+text vpx_codec_enc_init_multi_ver
text vpx_codec_encode
text vpx_codec_get_cx_data
text vpx_codec_get_global_headers
95 changes: 95 additions & 0 deletions mingw-w64-libvpx/PKGBUILD
@@ -0,0 +1,95 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libvpx
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.2
pkgrel=1
pkgdesc="The VP8 Codec SDK (mingw-w64)"
arch=('any')
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-yasm")
url="https://www.webmproject.org/"
source=(${_realname}-${pkgver}.tar.gz::https://github.com/webmproject/libvpx/archive/v${pkgver}.tar.gz
0001-enable-shared-on.mingw.patch
0002-no-pthreads.mingw.patch
0003-cross-with-native-binutils.mingw.patch
0005-fix-exports.mingw.patch)
options=('strip' 'staticlibs')
sha256sums=('8735d9fcd1a781ae6917f28f239a8aa358ce4864ba113ea18af4bb2dc8b474ac'
'f37a24525725cad215d73c538c0b06343b043f2b07553e7dc25835bd68af0695'
'3153cac1db87628de36d71e6638677a08c52afd6ada94b4d64ea00364bf20e4a'
'fabe7d4a756b33016947f741b1b5d8cbbf9aefd8862240645d0ed7bf7b4a3739'
'7c511b5df935278da2cba32b03b90582f360ab6786a5e32028bc82025193fabd')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
msg2 "Applying $1"
patch -Np1 -i "${srcdir}"/$1
}

del_file_exists() {
for _fname in "$@"
do
if [ -f $_fname ]; then
rm -rf $_fname
fi
done
}
# =========================================== #


prepare() {
cd ${srcdir}/${_realname}-${pkgver}

#apply_patch_with_msg 0001-enable-shared-on.mingw.patch
apply_patch_with_msg 0002-no-pthreads.mingw.patch
apply_patch_with_msg 0003-cross-with-native-binutils.mingw.patch
apply_patch_with_msg 0005-fix-exports.mingw.patch
}

build() {
if [ ${MINGW_CHOST} = "i686-w64-mingw32" ]; then
_targetarch="x86-win32-gcc"
EXTRA_CFLAGS="-mstackrealign"
else
_targetarch="x86_64-win64-gcc"
fi
mkdir -p ${srcdir}/build-${MINGW_CHOST}
cd "${srcdir}/build-${MINGW_CHOST}"
CFLAGS="$EXTRA_CFLAGS $CFLAGS -fno-asynchronous-unwind-tables" \
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--target=${_targetarch} \
--enable-vp8 \
--enable-vp9 \
--enable-vp9-highbitdepth \
--enable-vp9-temporal-denoising \
--enable-runtime-cpu-detect \
--enable-postproc \
--enable-pic \
--disable-shared \
--enable-static \
--enable-experimental \
--disable-examples \
--disable-docs \
--disable-install-docs \
--disable-install-srcs \
--disable-unit-tests

for _ff in *.mk; do
sed -i "s/HAVE_GNU_STRIP=yes/HAVE_GNU_STRIP=no/g" $_ff
done
make #-j1
}

#These tests seem to take a lot of time
#check() {
# cd "${srcdir}/build-$MINGW_CHOST"
# make test
#}

package() {
cd "${srcdir}/build-$MINGW_CHOST"
make DIST_DIR="${pkgdir}${MINGW_PREFIX}" install
}

0 comments on commit 9b427f4

Please sign in to comment.