From d56952d6dcdd23ca1396cface09632d76f770b0b Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Wed, 18 Mar 2015 14:55:07 -0400 Subject: [PATCH] vp8: fine-tune vpx encoder to support realtime encoding This patch uses lastest available revision of vpx library to profit of last bugfixes and performance improvements. Refs #68788 Change-Id: I71116ea7bab0307d5a797fe224f0059a9dafb52f --- daemon/contrib/src/vpx/libvpx-mac.patch | 18 ------------ daemon/contrib/src/vpx/libvpx-no-cross.patch | 10 ------- daemon/contrib/src/vpx/libvpx-sysroot.patch | 31 -------------------- daemon/contrib/src/vpx/rules.mak | 27 ++++++++++------- daemon/src/media/media_encoder.cpp | 8 +++++ 5 files changed, 24 insertions(+), 70 deletions(-) delete mode 100644 daemon/contrib/src/vpx/libvpx-mac.patch delete mode 100644 daemon/contrib/src/vpx/libvpx-no-cross.patch delete mode 100644 daemon/contrib/src/vpx/libvpx-sysroot.patch diff --git a/daemon/contrib/src/vpx/libvpx-mac.patch b/daemon/contrib/src/vpx/libvpx-mac.patch deleted file mode 100644 index ebb868ade3..0000000000 --- a/daemon/contrib/src/vpx/libvpx-mac.patch +++ /dev/null @@ -1,18 +0,0 @@ -libvpx's configure script hard-codes the SDK location of previous Xcode release in the /Developer folder. However, starting with Xcode 4.3, the SDKs moved to /Applications/Xcode.app/blabla -VLC's contrib system is clever enough to detect this, but libvpx fails miserably. However, they are providing a work-around for iOS and Android, which is expanded by this patch. - -diff -ru libvpx/build/make/configure.sh libvpx/build/make/configure.sh ---- libvpx/build/make/configure.sh 2012-06-08 10:26:47.000000000 +0200 -+++ libvpx-fixed/build/make/configure.sh 2012-06-08 10:26:07.000000000 +0200 -@@ -628,6 +628,11 @@ - if [ -d "/Developer/SDKs/MacOSX10.7.sdk" ]; then - osx_sdk_dir="/Developer/SDKs/MacOSX10.7.sdk" - fi -+ if [ -d "${sdk_path}" ]; then -+ case "${sdk_path}" in -+ darwin*) osx_sdk_dir=${sdk_path} ;; -+ esac -+ fi - - case ${toolchain} in - *-darwin8-*) diff --git a/daemon/contrib/src/vpx/libvpx-no-cross.patch b/daemon/contrib/src/vpx/libvpx-no-cross.patch deleted file mode 100644 index e261dc7773..0000000000 --- a/daemon/contrib/src/vpx/libvpx-no-cross.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- libvpx-v1.0.0/build/make/configure.sh.orig 2012-01-29 04:59:36.976441000 -0500 -+++ libvpx-v1.0.0/build/make/configure.sh 2012-01-29 04:59:46.684441001 -0500 -@@ -680,7 +680,6 @@ - - case ${tgt_cc} in - gcc) -- CROSS=${CROSS:-arm-none-linux-gnueabi-} - link_with_cc=gcc - setup_gnu_toolchain - arch_int=${tgt_isa##armv} diff --git a/daemon/contrib/src/vpx/libvpx-sysroot.patch b/daemon/contrib/src/vpx/libvpx-sysroot.patch deleted file mode 100644 index 9b843389d5..0000000000 --- a/daemon/contrib/src/vpx/libvpx-sysroot.patch +++ /dev/null @@ -1,31 +0,0 @@ -Our contrib system already passes the correct sysroot to the compiler, so there -is no need to set an alternate libc path. If that path is empty the script will -try to look for it in some fashion, but since the SDKROOT may be in a -non standard location the look up may fail. - -This patch avoids that case and relies on the user configuration for the -correct sysroot. - -See also https://code.google.com/p/webm/issues/detail?id=809 - -diff --git a/build/make/configure.sh b/build/make/configure.sh -index d4124c7..c420d25 100755 ---- a/build/make/configure.sh -+++ b/build/make/configure.sh -@@ -939,8 +939,11 @@ EOF - awk '{ print $1 }' | tail -1` - fi - -- add_cflags "--sysroot=${alt_libc}" -- add_ldflags "--sysroot=${alt_libc}" -+ # this may happen if toolchain binaries are outside the ndk dir -+ if [ "${alt_libc}" ]; then -+ add_cflags "--sysroot=${alt_libc}" -+ add_ldflags "--sysroot=${alt_libc}" -+ fi - - # linker flag that routes around a CPU bug in some - # Cortex-A8 implementations (NDK Dev Guide) --- -1.8.3.2 - diff --git a/daemon/contrib/src/vpx/rules.mak b/daemon/contrib/src/vpx/rules.mak index 3627664855..716a430bc1 100644 --- a/daemon/contrib/src/vpx/rules.mak +++ b/daemon/contrib/src/vpx/rules.mak @@ -1,18 +1,20 @@ # libvpx -VPX_VERSION := v1.3.0 -VPX_URL := http://webm.googlecode.com/files/libvpx-$(VPX_VERSION).tar.bz2 +VPX_HASH := 4640a0c4804b49f1870d5a2d17df0c7d0a77af2f +VPX_URL := http://libvpx.webm.googlecode.com/archive/$(VPX_HASH).tar.gz +#VPX_GITURL := https://code.google.com/p/webm.libvpx -$(TARBALLS)/libvpx-$(VPX_VERSION).tar.bz2: +$(TARBALLS)/libvpx-$(VPX_HASH).tar.gz: $(call download,$(VPX_URL)) -.sum-vpx: libvpx-$(VPX_VERSION).tar.bz2 +.sum-vpx: libvpx-$(VPX_HASH).tar.gz + $(warning $@ not implemented) + touch $@ -libvpx: libvpx-$(VPX_VERSION).tar.bz2 .sum-vpx - $(UNPACK) - $(APPLY) $(SRC)/vpx/libvpx-sysroot.patch - $(APPLY) $(SRC)/vpx/libvpx-no-cross.patch - $(APPLY) $(SRC)/vpx/libvpx-mac.patch +libvpx: libvpx-$(VPX_HASH).tar.gz .sum-vpx + rm -Rf $@-$(VPX_HASH) + mkdir -p $@-$(VPX_HASH) + (cd $@-$(VPX_HASH) && tar xv --strip-components=1 -f ../$<) $(MOVE) DEPS_vpx = @@ -72,12 +74,15 @@ endif VPX_CONF := \ --as=yasm \ - --enable-runtime-cpu-detect \ --disable-docs \ --disable-examples \ --disable-unit-tests \ --disable-install-bins \ - --disable-install-docs + --disable-install-docs \ + --enable-realtime-only \ + --enable-error-concealment \ + --disable-runtime-cpu-detect \ + --disable-webm-io ifndef HAVE_WIN32 VPX_CONF += --enable-pic diff --git a/daemon/src/media/media_encoder.cpp b/daemon/src/media/media_encoder.cpp index a2cf779409..5508dcc72e 100644 --- a/daemon/src/media/media_encoder.cpp +++ b/daemon/src/media/media_encoder.cpp @@ -131,7 +131,15 @@ MediaEncoder::openOutput(const char *filename, extractProfileLevelID(args.parameters, encoderCtx_); forcePresetX264(); } else if (args.codec->systemCodecInfo.avcodecId == AV_CODEC_ID_VP8) { + // Using information given on this page: + // http://www.webmproject.org/docs/encoder-parameters/ av_opt_set(encoderCtx_->priv_data, "quality", "realtime", 0); + av_opt_set_int(encoderCtx_->priv_data, "error-resilient", 1, 0); + av_opt_set_int(encoderCtx_->priv_data, "cpu-used", 3, 0); + encoderCtx_->slices = 2; // VP8E_SET_TOKEN_PARTITIONS + encoderCtx_->qmin = 4; + encoderCtx_->qmax = 56; + encoderCtx_->gop_size = 999999; } int ret; -- GitLab