diff --git a/starboard/shared/libvpx/vpx_video_decoder.h b/starboard/shared/libvpx/vpx_video_decoder.h index 6fe86b8a8ec2..a99bab6aba73 100644 --- a/starboard/shared/libvpx/vpx_video_decoder.h +++ b/starboard/shared/libvpx/vpx_video_decoder.h @@ -28,8 +28,8 @@ #include "starboard/shared/starboard/player/job_queue.h" #include "starboard/shared/starboard/player/job_thread.h" #include "starboard/thread.h" -#include "third_party/libvpx/vpx/vp8dx.h" -#include "third_party/libvpx/vpx/vpx_decoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8dx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_decoder.h" namespace starboard { namespace shared { diff --git a/third_party/libvpx/platforms/linux-x64/libvpx-linux-x64.sh b/third_party/libvpx/platforms/linux-x64/libvpx-linux-x64.sh index 1ff93ffb78c5..b105c0ed0a8c 100755 --- a/third_party/libvpx/platforms/linux-x64/libvpx-linux-x64.sh +++ b/third_party/libvpx/platforms/linux-x64/libvpx-linux-x64.sh @@ -17,7 +17,7 @@ set -ex readonly LIB_DIR="$(cd "$(dirname "$0")" && pwd)" -readonly SRC_DIR="$(cd "$(dirname "$0")/../.." && pwd)" +readonly SRC_DIR="$(cd "$(dirname "$0")/../../source/libvpx" && pwd)" (cd "${SRC_DIR}" && ./configure \ --target=x86_64-linux-gcc \ diff --git a/third_party/libvpx/platforms/linux-x64/libvpx.a b/third_party/libvpx/platforms/linux-x64/libvpx.a index 34b8c593b19e..6736b7803be4 100644 Binary files a/third_party/libvpx/platforms/linux-x64/libvpx.a and b/third_party/libvpx/platforms/linux-x64/libvpx.a differ diff --git a/third_party/libvpx/platforms/linux-x64/libvpx.so.6 b/third_party/libvpx/platforms/linux-x64/libvpx.so.6 index 9a61f0687bed..84fb5cb748fb 100755 Binary files a/third_party/libvpx/platforms/linux-x64/libvpx.so.6 and b/third_party/libvpx/platforms/linux-x64/libvpx.so.6 differ diff --git a/third_party/libvpx/.clang-format b/third_party/libvpx/source/libvpx/.clang-format similarity index 100% rename from third_party/libvpx/.clang-format rename to third_party/libvpx/source/libvpx/.clang-format diff --git a/third_party/libvpx/.gitattributes b/third_party/libvpx/source/libvpx/.gitattributes similarity index 100% rename from third_party/libvpx/.gitattributes rename to third_party/libvpx/source/libvpx/.gitattributes diff --git a/third_party/libvpx/.gitignore b/third_party/libvpx/source/libvpx/.gitignore similarity index 97% rename from third_party/libvpx/.gitignore rename to third_party/libvpx/source/libvpx/.gitignore index aeb6d58cc627..5f2683538656 100644 --- a/third_party/libvpx/.gitignore +++ b/third_party/libvpx/source/libvpx/.gitignore @@ -1,6 +1,5 @@ *.S *.a -!/platforms/*/libvpx.a *.asm.s *.d *.gcda diff --git a/third_party/libvpx/.mailmap b/third_party/libvpx/source/libvpx/.mailmap similarity index 96% rename from third_party/libvpx/.mailmap rename to third_party/libvpx/source/libvpx/.mailmap index 8d9750099477..376ca83ae3c4 100644 --- a/third_party/libvpx/.mailmap +++ b/third_party/libvpx/source/libvpx/.mailmap @@ -12,6 +12,8 @@ Deb Mukherjee Elliott Karpilovsky Erik Niemeyer Fyodor Kyslov +Gregor Jasny +Gregor Jasny Guillaume Martres Hangyu Kuang Hui Su diff --git a/third_party/libvpx/AUTHORS b/third_party/libvpx/source/libvpx/AUTHORS similarity index 97% rename from third_party/libvpx/AUTHORS rename to third_party/libvpx/source/libvpx/AUTHORS index 352c91feda0e..e804842f7889 100644 --- a/third_party/libvpx/AUTHORS +++ b/third_party/libvpx/source/libvpx/AUTHORS @@ -37,6 +37,7 @@ Christian Duvivier Clement Courbet Daniele Castagna Daniel Kang +Daniel Sommermann Dan Zhu Deb Mukherjee Deepa K G @@ -73,6 +74,7 @@ Ivan Maltz Jacek Caban Jacky Chen James Berry +James Touton James Yu James Zern Jan Gerber @@ -82,11 +84,14 @@ Jean-Yves Avenard Jeff Faust Jeff Muizelaar Jeff Petkau +Jeremy Leconte Jerome Jiang Jia Jia Jian Zhou Jim Bankoski +jinbo Jingning Han +Joel Fernandes Joey Parrish Johann Koenig John Koleszar diff --git a/third_party/libvpx/CHANGELOG b/third_party/libvpx/source/libvpx/CHANGELOG similarity index 96% rename from third_party/libvpx/CHANGELOG rename to third_party/libvpx/source/libvpx/CHANGELOG index e731fc6121d1..6338caa380bc 100644 --- a/third_party/libvpx/CHANGELOG +++ b/third_party/libvpx/source/libvpx/CHANGELOG @@ -1,3 +1,33 @@ +2021-03-09 v1.10.0 "Ruddy Duck" + This maintenance release adds support for darwin20 and new codec controls, as + well as numerous bug fixes. + + - Upgrading: + New codec control is added to disable loopfilter for VP9. + + New encoder control is added to disable feature to increase Q on overshoot + detection for CBR. + + Configure support for darwin20 is added. + + New codec control is added for VP9 rate control. The control ID of this + interface is VP9E_SET_EXTERNAL_RATE_CONTROL. To make VP9 use a customized + external rate control model, users will have to implement each callback + function in vpx_rc_funcs_t and register them using libvpx API + vpx_codec_control_() with the control ID. + + - Enhancement: + Use -std=gnu++11 instead of -std=c++11 for c++ files. + + - Bug fixes: + Override assembler with --as option of configure for MSVS. + Fix several compilation issues with gcc 4.8.5. + Fix to resetting rate control for temporal layers. + Fix to the rate control stats of SVC example encoder when number of spatial + layers is 1. + Fix to reusing motion vectors from the base spatial layer in SVC. + 2 pass related flags removed from SVC example encoder. + 2020-07-29 v1.9.0 "Quacking Duck" This release adds support for NV12, a separate library for rate control, as well as incremental improvements. diff --git a/third_party/libvpx/CONTRIBUTING.md b/third_party/libvpx/source/libvpx/CONTRIBUTING.md similarity index 85% rename from third_party/libvpx/CONTRIBUTING.md rename to third_party/libvpx/source/libvpx/CONTRIBUTING.md index 577c96a6b5df..7a73a30317af 100644 --- a/third_party/libvpx/CONTRIBUTING.md +++ b/third_party/libvpx/source/libvpx/CONTRIBUTING.md @@ -19,10 +19,9 @@ again. All submissions, including submissions by project members, require review. We use a [Gerrit](https://www.gerritcodereview.com) instance hosted at -https://chromium-review.googlesource.com for this purpose. - -See https://www.webmproject.org/code/contribute/submitting-patches for an -example of a typical gerrit workflow. +https://chromium-review.googlesource.com for this purpose. See the +[WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/) +for additional details. ## Community Guidelines diff --git a/third_party/libvpx/LICENSE b/third_party/libvpx/source/libvpx/LICENSE similarity index 100% rename from third_party/libvpx/LICENSE rename to third_party/libvpx/source/libvpx/LICENSE diff --git a/third_party/libvpx/METADATA b/third_party/libvpx/source/libvpx/METADATA similarity index 65% rename from third_party/libvpx/METADATA rename to third_party/libvpx/source/libvpx/METADATA index 59fdc591a71b..4ec31ac29f39 100644 --- a/third_party/libvpx/METADATA +++ b/third_party/libvpx/source/libvpx/METADATA @@ -7,8 +7,8 @@ third_party { type: GIT value: "https://chromium.googlesource.com/webm/libvpx" } - version: "53747dfe65eaf670a7192f55117f3bf1e0280743" - # from https://chromium.googlesource.com/chromium/src/+/86.0.4240.199/DEPS#1152 + version: "7aabd6968278130da885f6c35ee12b19a1e7be72" + # from https://chromium.googlesource.com/chromium/src/+/96.0.4664.219/DEPS#1305 last_upgrade_date { year: 2020 month: 7 diff --git a/third_party/libvpx/PATENTS b/third_party/libvpx/source/libvpx/PATENTS similarity index 100% rename from third_party/libvpx/PATENTS rename to third_party/libvpx/source/libvpx/PATENTS diff --git a/third_party/libvpx/README b/third_party/libvpx/source/libvpx/README similarity index 92% rename from third_party/libvpx/README rename to third_party/libvpx/source/libvpx/README index fd4c93a4655c..ddbcb9f69561 100644 --- a/third_party/libvpx/README +++ b/third_party/libvpx/source/libvpx/README @@ -1,4 +1,4 @@ -README - 20 July 2020 +README - 08 March 2021 Welcome to the WebM VP8/VP9 Codec SDK! @@ -10,14 +10,14 @@ COMPILING THE APPLICATIONS/LIBRARIES: 1. Prerequisites * All x86 targets require the Yasm[1] assembler be installed[2]. - * All Windows builds require that Cygwin[3] be installed. - * Building the documentation requires Doxygen[4]. If you do not + * All Windows builds require that Cygwin[3] or MSYS2[4] be installed. + * Building the documentation requires Doxygen[5]. If you do not have this package, the install-docs option will be disabled. - * Downloading the data for the unit tests requires curl[5] and sha1sum. + * Downloading the data for the unit tests requires curl[6] and sha1sum. sha1sum is provided via the GNU coreutils, installed by default on many *nix platforms, as well as MinGW and Cygwin. If coreutils is not available, a compatible version of sha1sum can be built from - source[6]. These requirements are optional if not running the unit + source[7]. These requirements are optional if not running the unit tests. [1]: http://www.tortall.net/projects/yasm @@ -26,9 +26,10 @@ COMPILING THE APPLICATIONS/LIBRARIES: yasm--.exe to yasm.exe and place it in: Program Files (x86)/Microsoft Visual Studio/2017//Common7/Tools/ [3]: http://www.cygwin.com - [4]: http://www.doxygen.org - [5]: http://curl.haxx.se - [6]: http://www.microbrew.org/tools/md5sha1sum/ + [4]: http://www.msys2.org/ + [5]: http://www.doxygen.org + [6]: http://curl.haxx.se + [7]: http://www.microbrew.org/tools/md5sha1sum/ 2. Out-of-tree builds Out of tree builds are a supported method of building the application. For @@ -62,6 +63,7 @@ COMPILING THE APPLICATIONS/LIBRARIES: arm64-android-gcc arm64-darwin-gcc + arm64-darwin20-gcc arm64-linux-gcc arm64-win64-gcc arm64-win64-vs15 @@ -113,6 +115,7 @@ COMPILING THE APPLICATIONS/LIBRARIES: x86_64-darwin17-gcc x86_64-darwin18-gcc x86_64-darwin19-gcc + x86_64-darwin20-gcc x86_64-iphonesimulator-gcc x86_64-linux-gcc x86_64-linux-icc diff --git a/third_party/libvpx/args.c b/third_party/libvpx/source/libvpx/args.c similarity index 97% rename from third_party/libvpx/args.c rename to third_party/libvpx/source/libvpx/args.c index a87b138b9d78..17b615584e7f 100644 --- a/third_party/libvpx/args.c +++ b/third_party/libvpx/source/libvpx/args.c @@ -16,8 +16,10 @@ #include "vpx/vpx_integer.h" #include "vpx_ports/msvc.h" -#if defined(__GNUC__) && __GNUC__ -extern void die(const char *fmt, ...) __attribute__((noreturn)); +#if defined(__GNUC__) +__attribute__((noreturn)) extern void die(const char *fmt, ...); +#elif defined(_MSC_VER) +__declspec(noreturn) extern void die(const char *fmt, ...); #else extern void die(const char *fmt, ...); #endif diff --git a/third_party/libvpx/args.h b/third_party/libvpx/source/libvpx/args.h similarity index 100% rename from third_party/libvpx/args.h rename to third_party/libvpx/source/libvpx/args.h diff --git a/third_party/libvpx/build/make/Android.mk b/third_party/libvpx/source/libvpx/build/make/Android.mk similarity index 100% rename from third_party/libvpx/build/make/Android.mk rename to third_party/libvpx/source/libvpx/build/make/Android.mk diff --git a/third_party/libvpx/build/make/Makefile b/third_party/libvpx/source/libvpx/build/make/Makefile similarity index 99% rename from third_party/libvpx/build/make/Makefile rename to third_party/libvpx/source/libvpx/build/make/Makefile index be2810229577..9ca97c8c6406 100644 --- a/third_party/libvpx/build/make/Makefile +++ b/third_party/libvpx/source/libvpx/build/make/Makefile @@ -147,6 +147,10 @@ $(BUILD_PFX)%_avx512.c.o: CFLAGS += -mavx512f -mavx512cd -mavx512bw -mavx512dq - $(BUILD_PFX)%_vsx.c.d: CFLAGS += -maltivec -mvsx $(BUILD_PFX)%_vsx.c.o: CFLAGS += -maltivec -mvsx +# MIPS +$(BUILD_PFX)%_msa.c.d: CFLAGS += -mmsa +$(BUILD_PFX)%_msa.c.o: CFLAGS += -mmsa + $(BUILD_PFX)%.c.d: %.c $(if $(quiet),@echo " [DEP] $@") $(qexec)mkdir -p $(dir $@) diff --git a/third_party/libvpx/build/make/ads2armasm_ms.pl b/third_party/libvpx/source/libvpx/build/make/ads2armasm_ms.pl similarity index 100% rename from third_party/libvpx/build/make/ads2armasm_ms.pl rename to third_party/libvpx/source/libvpx/build/make/ads2armasm_ms.pl diff --git a/third_party/libvpx/build/make/ads2gas.pl b/third_party/libvpx/source/libvpx/build/make/ads2gas.pl similarity index 100% rename from third_party/libvpx/build/make/ads2gas.pl rename to third_party/libvpx/source/libvpx/build/make/ads2gas.pl diff --git a/third_party/libvpx/build/make/ads2gas_apple.pl b/third_party/libvpx/source/libvpx/build/make/ads2gas_apple.pl similarity index 100% rename from third_party/libvpx/build/make/ads2gas_apple.pl rename to third_party/libvpx/source/libvpx/build/make/ads2gas_apple.pl diff --git a/third_party/libvpx/build/make/armlink_adapter.sh b/third_party/libvpx/source/libvpx/build/make/armlink_adapter.sh similarity index 100% rename from third_party/libvpx/build/make/armlink_adapter.sh rename to third_party/libvpx/source/libvpx/build/make/armlink_adapter.sh diff --git a/third_party/libvpx/build/make/configure.sh b/third_party/libvpx/source/libvpx/build/make/configure.sh similarity index 97% rename from third_party/libvpx/build/make/configure.sh rename to third_party/libvpx/source/libvpx/build/make/configure.sh index 206b54f775c1..81d30a16c7aa 100644 --- a/third_party/libvpx/build/make/configure.sh +++ b/third_party/libvpx/source/libvpx/build/make/configure.sh @@ -262,6 +262,9 @@ if [ -z "$source_path" ] || [ "$source_path" = "." ]; then source_path="`pwd`" disable_feature source_path_used fi +# Makefiles greedily process the '#' character as a comment, even if it is +# inside quotes. So, this character must be escaped in all paths in Makefiles. +source_path_mk=$(echo $source_path | sed -e 's;\#;\\\#;g') if test ! -z "$TMPDIR" ; then TMPDIRx="${TMPDIR}" @@ -481,11 +484,11 @@ write_common_target_config_mk() { cat >> $1 << EOF # This file automatically generated by configure. Do not edit! -SRC_PATH="$source_path" -SRC_PATH_BARE=$source_path +SRC_PATH="$source_path_mk" +SRC_PATH_BARE=$source_path_mk BUILD_PFX=${BUILD_PFX} TOOLCHAIN=${toolchain} -ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl} +ASM_CONVERSION=${asm_conversion_cmd:-${source_path_mk}/build/make/ads2gas.pl} GEN_VCPROJ=${gen_vcproj_cmd} MSVS_ARCH_DIR=${msvs_arch_dir} @@ -771,6 +774,10 @@ process_common_toolchain() { tgt_isa=x86_64 tgt_os=`echo $gcctarget | sed 's/.*\(darwin1[0-9]\).*/\1/'` ;; + *darwin20*) + tgt_isa=`uname -m` + tgt_os=`echo $gcctarget | sed 's/.*\(darwin2[0-9]\).*/\1/'` + ;; x86_64*mingw32*) tgt_os=win64 ;; @@ -845,7 +852,7 @@ process_common_toolchain() { # Handle darwin variants. Newer SDKs allow targeting older # platforms, so use the newest one available. case ${toolchain} in - arm*-darwin*) + arm*-darwin-*) add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)" if [ -d "${iphoneos_sdk_dir}" ]; then @@ -853,7 +860,7 @@ process_common_toolchain() { add_ldflags "-isysroot ${iphoneos_sdk_dir}" fi ;; - x86*-darwin*) + *-darwin*) osx_sdk_dir="$(show_darwin_sdk_path macosx)" if [ -d "${osx_sdk_dir}" ]; then add_cflags "-isysroot ${osx_sdk_dir}" @@ -911,6 +918,10 @@ process_common_toolchain() { add_cflags "-mmacosx-version-min=10.15" add_ldflags "-mmacosx-version-min=10.15" ;; + *-darwin20-*) + add_cflags "-mmacosx-version-min=10.16 -arch ${toolchain%%-*}" + add_ldflags "-mmacosx-version-min=10.16 -arch ${toolchain%%-*}" + ;; *-iphonesimulator-*) add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}" @@ -984,7 +995,7 @@ EOF fi enabled debug && add_asflags -g - asm_conversion_cmd="${source_path}/build/make/ads2gas.pl" + asm_conversion_cmd="${source_path_mk}/build/make/ads2gas.pl" case ${tgt_os} in win*) @@ -1006,7 +1017,7 @@ EOF # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs # and so can be selected as 'win32'. if [ ${tgt_os} = "win32" ]; then - asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl" + asm_conversion_cmd="${source_path_mk}/build/make/ads2armasm_ms.pl" AS_SFX=.S msvs_arch_dir=arm-msvs disable_feature multithread @@ -1084,7 +1095,7 @@ EOF soft_enable unit_tests ;; - darwin*) + darwin) if ! enabled external_build; then XCRUN_FIND="xcrun --sdk iphoneos --find" CXX="$(${XCRUN_FIND} clang++)" @@ -1141,7 +1152,7 @@ EOF fi fi - asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl" + asm_conversion_cmd="${source_path_mk}/build/make/ads2gas_apple.pl" ;; linux*) @@ -1195,25 +1206,27 @@ EOF check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64 check_add_ldflags -mips64r6 -mabi=64 -mfp64 ;; + loongson3*) + check_cflags -march=loongson3a && soft_enable mmi \ + || disable_feature mmi + check_cflags -mmsa && soft_enable msa \ + || disable_feature msa + tgt_isa=loongson3a + ;; esac + if enabled mmi || enabled msa; then + soft_enable runtime_cpu_detect + fi + if enabled msa; then # TODO(libyuv:793) # The new mips functions in libyuv do not build # with the toolchains we currently use for testing. soft_disable libyuv - - add_cflags -mmsa - add_asflags -mmsa - add_ldflags -mmsa fi fi - if enabled mmi; then - tgt_isa=loongson3a - check_add_ldflags -march=loongson3a - fi - check_add_cflags -march=${tgt_isa} check_add_asflags -march=${tgt_isa} check_add_asflags -KPIC @@ -1283,10 +1296,6 @@ EOF enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer ;; vs*) - # When building with Microsoft Visual Studio the assembler is - # invoked directly. Checking at configure time is unnecessary. - # Skip the check by setting AS arbitrarily - AS=msvs msvs_arch_dir=x86-msvs case ${tgt_cc##vs} in 14) diff --git a/third_party/libvpx/build/make/gen_asm_deps.sh b/third_party/libvpx/source/libvpx/build/make/gen_asm_deps.sh similarity index 100% rename from third_party/libvpx/build/make/gen_asm_deps.sh rename to third_party/libvpx/source/libvpx/build/make/gen_asm_deps.sh diff --git a/third_party/libvpx/build/make/gen_msvs_def.sh b/third_party/libvpx/source/libvpx/build/make/gen_msvs_def.sh similarity index 100% rename from third_party/libvpx/build/make/gen_msvs_def.sh rename to third_party/libvpx/source/libvpx/build/make/gen_msvs_def.sh diff --git a/third_party/libvpx/build/make/gen_msvs_sln.sh b/third_party/libvpx/source/libvpx/build/make/gen_msvs_sln.sh similarity index 100% rename from third_party/libvpx/build/make/gen_msvs_sln.sh rename to third_party/libvpx/source/libvpx/build/make/gen_msvs_sln.sh diff --git a/third_party/libvpx/build/make/gen_msvs_vcxproj.sh b/third_party/libvpx/source/libvpx/build/make/gen_msvs_vcxproj.sh similarity index 98% rename from third_party/libvpx/build/make/gen_msvs_vcxproj.sh rename to third_party/libvpx/source/libvpx/build/make/gen_msvs_vcxproj.sh index bb1c31d230da..6f91ad47817d 100755 --- a/third_party/libvpx/build/make/gen_msvs_vcxproj.sh +++ b/third_party/libvpx/source/libvpx/build/make/gen_msvs_vcxproj.sh @@ -157,6 +157,8 @@ for opt in "$@"; do ;; --lib) proj_kind="lib" ;; + --as=*) as="${optval}" + ;; --src-path-bare=*) src_path_bare=$(fix_path "$optval") src_path_bare=${src_path_bare%/} @@ -247,13 +249,13 @@ libs=${libs// /;} case "$target" in x86_64*) platforms[0]="x64" - asm_Debug_cmdline="yasm -Xvc -g cv8 -f win64 ${yasmincs} "%(FullPath)"" - asm_Release_cmdline="yasm -Xvc -f win64 ${yasmincs} "%(FullPath)"" + asm_Debug_cmdline="${as} -Xvc -gcv8 -f win64 ${yasmincs} "%(FullPath)"" + asm_Release_cmdline="${as} -Xvc -f win64 ${yasmincs} "%(FullPath)"" ;; x86*) platforms[0]="Win32" - asm_Debug_cmdline="yasm -Xvc -g cv8 -f win32 ${yasmincs} "%(FullPath)"" - asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} "%(FullPath)"" + asm_Debug_cmdline="${as} -Xvc -gcv8 -f win32 ${yasmincs} "%(FullPath)"" + asm_Release_cmdline="${as} -Xvc -f win32 ${yasmincs} "%(FullPath)"" ;; arm64*) platforms[0]="ARM64" diff --git a/third_party/libvpx/build/make/ios-Info.plist b/third_party/libvpx/source/libvpx/build/make/ios-Info.plist similarity index 100% rename from third_party/libvpx/build/make/ios-Info.plist rename to third_party/libvpx/source/libvpx/build/make/ios-Info.plist diff --git a/third_party/libvpx/build/make/iosbuild.sh b/third_party/libvpx/source/libvpx/build/make/iosbuild.sh similarity index 100% rename from third_party/libvpx/build/make/iosbuild.sh rename to third_party/libvpx/source/libvpx/build/make/iosbuild.sh diff --git a/third_party/libvpx/build/make/msvs_common.sh b/third_party/libvpx/source/libvpx/build/make/msvs_common.sh similarity index 96% rename from third_party/libvpx/build/make/msvs_common.sh rename to third_party/libvpx/source/libvpx/build/make/msvs_common.sh index 27ddf7fd91d7..3989fec0d518 100644 --- a/third_party/libvpx/build/make/msvs_common.sh +++ b/third_party/libvpx/source/libvpx/build/make/msvs_common.sh @@ -9,7 +9,8 @@ ## be found in the AUTHORS file in the root of the source tree. ## -if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] \ +shell_name="$(uname -o 2>/dev/null)" +if [[ "$shell_name" = "Cygwin" || "$shell_name" = "Msys" ]] \ && cygpath --help >/dev/null 2>&1; then FIXPATH='cygpath -m' else diff --git a/third_party/libvpx/build/make/rtcd.pl b/third_party/libvpx/source/libvpx/build/make/rtcd.pl similarity index 92% rename from third_party/libvpx/build/make/rtcd.pl rename to third_party/libvpx/source/libvpx/build/make/rtcd.pl index 7483200411a7..acb9f6e46673 100755 --- a/third_party/libvpx/build/make/rtcd.pl +++ b/third_party/libvpx/source/libvpx/build/make/rtcd.pl @@ -315,14 +315,26 @@ () sub mips() { determine_indirection("c", @ALL_ARCHS); + + # Assign the helper variable for each enabled extension + foreach my $opt (@ALL_ARCHS) { + my $opt_uc = uc $opt; + eval "\$have_${opt}=\"flags & HAS_${opt_uc}\""; + } + common_top; print <) { if (/HAVE_DSPR2=yes/) { - @ALL_ARCHS = filter("$opts{arch}", qw/dspr2/); - last; + $have_dspr2 = 1; } if (/HAVE_MSA=yes/) { - @ALL_ARCHS = filter("$opts{arch}", qw/msa/); - last; + $have_msa = 1; } if (/HAVE_MMI=yes/) { - @ALL_ARCHS = filter("$opts{arch}", qw/mmi/); - last; + $have_mmi = 1; } } close CONFIG_FILE; + if ($have_dspr2 == 1) { + @ALL_ARCHS = filter("$opts{arch}", qw/dspr2/); + } elsif ($have_msa == 1 && $have_mmi == 1) { + @ALL_ARCHS = filter("$opts{arch}", qw/mmi msa/); + } elsif ($have_msa == 1) { + @ALL_ARCHS = filter("$opts{arch}", qw/msa/); + } elsif ($have_mmi == 1) { + @ALL_ARCHS = filter("$opts{arch}", qw/mmi/); + } else { + unoptimized; + } mips; } elsif ($opts{arch} =~ /armv7\w?/) { @ALL_ARCHS = filter(qw/neon_asm neon/); diff --git a/third_party/libvpx/build/make/thumb.pm b/third_party/libvpx/source/libvpx/build/make/thumb.pm similarity index 100% rename from third_party/libvpx/build/make/thumb.pm rename to third_party/libvpx/source/libvpx/build/make/thumb.pm diff --git a/third_party/libvpx/build/make/version.sh b/third_party/libvpx/source/libvpx/build/make/version.sh similarity index 100% rename from third_party/libvpx/build/make/version.sh rename to third_party/libvpx/source/libvpx/build/make/version.sh diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/cur_frame_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/cur_frame_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/cur_frame_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/cur_frame_16x16.txt diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/estimation_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/estimation_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/estimation_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/estimation_16x16.txt diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/exhaust_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/exhaust_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/exhaust_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/exhaust_16x16.txt diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/ground_truth_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/ground_truth_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/ground_truth_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/ground_truth_16x16.txt diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/localVar_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/localVar_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/localVar_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/localVar_16x16.txt diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/raw_1.png b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/raw_1.png similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/raw_1.png rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/raw_1.png diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/raw_1_12_12.png b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/raw_1_12_12.png similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/raw_1_12_12.png rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/raw_1_12_12.png diff --git a/third_party/libvpx/build_debug/non_greedy_mv_test_files/ref_frame_16x16.txt b/third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/ref_frame_16x16.txt similarity index 100% rename from third_party/libvpx/build_debug/non_greedy_mv_test_files/ref_frame_16x16.txt rename to third_party/libvpx/source/libvpx/build_debug/non_greedy_mv_test_files/ref_frame_16x16.txt diff --git a/third_party/libvpx/codereview.settings b/third_party/libvpx/source/libvpx/codereview.settings similarity index 100% rename from third_party/libvpx/codereview.settings rename to third_party/libvpx/source/libvpx/codereview.settings diff --git a/third_party/libvpx/configure b/third_party/libvpx/source/libvpx/configure similarity index 98% rename from third_party/libvpx/configure rename to third_party/libvpx/source/libvpx/configure index 32272ce36fed..da631a45e1bf 100755 --- a/third_party/libvpx/configure +++ b/third_party/libvpx/source/libvpx/configure @@ -99,6 +99,7 @@ EOF # alphabetically by architecture, generic-gnu last. all_platforms="${all_platforms} arm64-android-gcc" all_platforms="${all_platforms} arm64-darwin-gcc" +all_platforms="${all_platforms} arm64-darwin20-gcc" all_platforms="${all_platforms} arm64-linux-gcc" all_platforms="${all_platforms} arm64-win64-gcc" all_platforms="${all_platforms} arm64-win64-vs15" @@ -150,6 +151,7 @@ all_platforms="${all_platforms} x86_64-darwin16-gcc" all_platforms="${all_platforms} x86_64-darwin17-gcc" all_platforms="${all_platforms} x86_64-darwin18-gcc" all_platforms="${all_platforms} x86_64-darwin19-gcc" +all_platforms="${all_platforms} x86_64-darwin20-gcc" all_platforms="${all_platforms} x86_64-iphonesimulator-gcc" all_platforms="${all_platforms} x86_64-linux-gcc" all_platforms="${all_platforms} x86_64-linux-icc" @@ -729,33 +731,33 @@ process_toolchain() { soft_enable libyuv ;; *-android-*) - check_add_cxxflags -std=c++11 && soft_enable webm_io + check_add_cxxflags -std=gnu++11 && soft_enable webm_io soft_enable libyuv # GTestLog must be modified to use Android logging utilities. ;; *-darwin-*) - check_add_cxxflags -std=c++11 + check_add_cxxflags -std=gnu++11 # iOS/ARM builds do not work with gtest. This does not match # x86 targets. ;; *-iphonesimulator-*) - check_add_cxxflags -std=c++11 && soft_enable webm_io + check_add_cxxflags -std=gnu++11 && soft_enable webm_io soft_enable libyuv ;; *-win*) # Some mingw toolchains don't have pthread available by default. # Treat these more like visual studio where threading in gtest # would be disabled for the same reason. - check_add_cxxflags -std=c++11 && soft_enable unit_tests \ + check_add_cxxflags -std=gnu++11 && soft_enable unit_tests \ && soft_enable webm_io check_cxx "$@" < 2) { - die("Error: Invalid number of passes (%d)\n", passes); - } - } else if (arg_match(&arg, &pass_arg, argi)) { - pass = arg_parse_uint(&arg); - if (pass < 1 || pass > 2) { - die("Error: Invalid pass selected (%d)\n", pass); - } - } else if (arg_match(&arg, &fpf_name_arg, argi)) { - fpf_file_name = arg.val; } else if (arg_match(&arg, &min_q_arg, argi)) { strncat(string_options, " min-quantizers=", sizeof(string_options) - strlen(string_options) - 1); @@ -355,35 +329,7 @@ static void parse_command_line(int argc, const char **argv_, if (strlen(string_options) > 0) vpx_svc_set_options(svc_ctx, string_options + 1); - if (passes == 0 || passes == 1) { - if (pass) { - fprintf(stderr, "pass is ignored since there's only one pass\n"); - } - enc_cfg->g_pass = VPX_RC_ONE_PASS; - } else { - if (pass == 0) { - die("pass must be specified when passes is 2\n"); - } - - if (fpf_file_name == NULL) { - die("fpf must be specified when passes is 2\n"); - } - - if (pass == 1) { - enc_cfg->g_pass = VPX_RC_FIRST_PASS; - if (!stats_open_file(&app_input->rc_stats, fpf_file_name, 0)) { - fatal("Failed to open statistics store"); - } - } else { - enc_cfg->g_pass = VPX_RC_LAST_PASS; - if (!stats_open_file(&app_input->rc_stats, fpf_file_name, 1)) { - fatal("Failed to open statistics store"); - } - enc_cfg->rc_twopass_stats_in = stats_get(&app_input->rc_stats); - } - app_input->passes = passes; - app_input->pass = pass; - } + enc_cfg->g_pass = VPX_RC_ONE_PASS; if (enc_cfg->rc_target_bitrate > 0) { if (min_bitrate > 0) { @@ -1004,13 +950,11 @@ int main(int argc, const char **argv) { info.time_base.numerator = enc_cfg.g_timebase.num; info.time_base.denominator = enc_cfg.g_timebase.den; - if (!(app_input.passes == 2 && app_input.pass == 1)) { - // We don't save the bitstream for the 1st pass on two pass rate control - writer = - vpx_video_writer_open(app_input.output_filename, kContainerIVF, &info); - if (!writer) - die("Failed to open %s for writing\n", app_input.output_filename); - } + writer = + vpx_video_writer_open(app_input.output_filename, kContainerIVF, &info); + if (!writer) + die("Failed to open %s for writing\n", app_input.output_filename); + #if OUTPUT_RC_STATS // Write out spatial layer stream. // TODO(marpan/jianj): allow for writing each spatial and temporal stream. @@ -1053,6 +997,9 @@ int main(int argc, const char **argv) { vpx_codec_control(&encoder, VP9E_SET_TUNE_CONTENT, app_input.tune_content); + vpx_codec_control(&encoder, VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, 0); + vpx_codec_control(&encoder, VP9E_SET_DISABLE_LOOPFILTER, 0); + svc_drop_frame.framedrop_mode = FULL_SUPERFRAME_DROP; for (sl = 0; sl < (unsigned int)svc_ctx.spatial_layers; ++sl) svc_drop_frame.framedrop_thresh[sl] = enc_cfg.rc_dropframe_thresh; @@ -1227,7 +1174,6 @@ int main(int argc, const char **argv) { #endif if (vpx_codec_destroy(&encoder)) die_codec(&encoder, "Failed to destroy codec"); - if (app_input.passes == 2) stats_close(&app_input.rc_stats, 1); if (writer) { vpx_video_writer_close(writer); } diff --git a/third_party/libvpx/examples/vp9cx_set_ref.c b/third_party/libvpx/source/libvpx/examples/vp9cx_set_ref.c similarity index 100% rename from third_party/libvpx/examples/vp9cx_set_ref.c rename to third_party/libvpx/source/libvpx/examples/vp9cx_set_ref.c diff --git a/third_party/libvpx/examples/vpx_dec_fuzzer.cc b/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc similarity index 98% rename from third_party/libvpx/examples/vpx_dec_fuzzer.cc rename to third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc index 34c0e112383b..5eba9d74daa8 100644 --- a/third_party/libvpx/examples/vpx_dec_fuzzer.cc +++ b/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc @@ -41,7 +41,7 @@ $make -j32 * Build vp9 fuzzer - $ $CXX $CXXFLAGS -std=c++11 -DDECODER=vp9 \ + $ $CXX $CXXFLAGS -std=gnu++11 -DDECODER=vp9 \ -fsanitize=fuzzer -I../libvpx -I. -Wl,--start-group \ ../libvpx/examples/vpx_dec_fuzzer.cc -o ./vpx_dec_fuzzer_vp9 \ ./libvpx.a -Wl,--end-group diff --git a/third_party/libvpx/examples/vpx_temporal_svc_encoder.c b/third_party/libvpx/source/libvpx/examples/vpx_temporal_svc_encoder.c similarity index 99% rename from third_party/libvpx/examples/vpx_temporal_svc_encoder.c rename to third_party/libvpx/source/libvpx/examples/vpx_temporal_svc_encoder.c index 872751cefeea..ad3e79c713af 100644 --- a/third_party/libvpx/examples/vpx_temporal_svc_encoder.c +++ b/third_party/libvpx/source/libvpx/examples/vpx_temporal_svc_encoder.c @@ -831,6 +831,8 @@ int main(int argc, char **argv) { } else if (strncmp(encoder->name, "vp9", 3) == 0) { vpx_svc_extra_cfg_t svc_params; memset(&svc_params, 0, sizeof(svc_params)); + vpx_codec_control(&codec, VP9E_SET_POSTENCODE_DROP, 0); + vpx_codec_control(&codec, VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, 0); vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); vpx_codec_control(&codec, VP9E_SET_GF_CBR_BOOST_PCT, 0); @@ -840,6 +842,7 @@ int main(int argc, char **argv) { vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1); vpx_codec_control(&codec, VP9E_SET_TUNE_CONTENT, 0); vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, get_msb(cfg.g_threads)); + vpx_codec_control(&codec, VP9E_SET_DISABLE_LOOPFILTER, 0); #if ROI_MAP set_roi_map(encoder->name, &cfg, &roi); if (vpx_codec_control(&codec, VP9E_SET_ROI_MAP, &roi)) @@ -928,6 +931,7 @@ int main(int argc, char **argv) { // Update for short-time encoding bitrate states, for moving window // of size rc->window, shifted by rc->window / 2. // Ignore first window segment, due to key frame. + if (rc.window_size == 0) rc.window_size = 15; if (frame_cnt > rc.window_size) { sum_bitrate += 0.001 * 8.0 * pkt->data.frame.sz * framerate; if (frame_cnt % rc.window_size == 0) { diff --git a/third_party/libvpx/ivfdec.c b/third_party/libvpx/source/libvpx/ivfdec.c similarity index 100% rename from third_party/libvpx/ivfdec.c rename to third_party/libvpx/source/libvpx/ivfdec.c diff --git a/third_party/libvpx/ivfdec.h b/third_party/libvpx/source/libvpx/ivfdec.h similarity index 100% rename from third_party/libvpx/ivfdec.h rename to third_party/libvpx/source/libvpx/ivfdec.h diff --git a/third_party/libvpx/ivfenc.c b/third_party/libvpx/source/libvpx/ivfenc.c similarity index 100% rename from third_party/libvpx/ivfenc.c rename to third_party/libvpx/source/libvpx/ivfenc.c diff --git a/third_party/libvpx/ivfenc.h b/third_party/libvpx/source/libvpx/ivfenc.h similarity index 100% rename from third_party/libvpx/ivfenc.h rename to third_party/libvpx/source/libvpx/ivfenc.h diff --git a/third_party/libvpx/keywords.dox b/third_party/libvpx/source/libvpx/keywords.dox similarity index 100% rename from third_party/libvpx/keywords.dox rename to third_party/libvpx/source/libvpx/keywords.dox diff --git a/third_party/libvpx/libs.doxy_template b/third_party/libvpx/source/libvpx/libs.doxy_template similarity index 100% rename from third_party/libvpx/libs.doxy_template rename to third_party/libvpx/source/libvpx/libs.doxy_template diff --git a/third_party/libvpx/libs.mk b/third_party/libvpx/source/libvpx/libs.mk similarity index 92% rename from third_party/libvpx/libs.mk rename to third_party/libvpx/source/libvpx/libs.mk index 78f2c927860a..d4763efca03d 100644 --- a/third_party/libvpx/libs.mk +++ b/third_party/libvpx/source/libvpx/libs.mk @@ -63,6 +63,7 @@ ifeq ($(CONFIG_VP8_ENCODER),yes) CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS)) CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS)) INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h + INSTALL-LIBS-yes += include/vpx/vpx_ext_ratectrl.h INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/% CODEC_DOC_SECTIONS += vp8 vp8_encoder endif @@ -87,18 +88,34 @@ ifeq ($(CONFIG_VP9_ENCODER),yes) CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS)) CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h + CODEC_SRCS-yes += vpx/vpx_ext_ratectrl.h INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h + INSTALL-LIBS-yes += include/vpx/vpx_ext_ratectrl.h INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% - CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h + CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h vpx/vpx_ext_ratectrl.h CODEC_DOC_SECTIONS += vp9 vp9_encoder +endif - RC_RTC_SRCS := $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) - RC_RTC_SRCS += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h +RC_RTC_SRCS := vpx/vp8.h vpx/vp8cx.h +RC_RTC_SRCS += vpx/vpx_ext_ratectrl.h +RC_RTC_SRCS += vpx/internal/vpx_ratectrl_rtc.h +ifeq ($(CONFIG_VP9_ENCODER),yes) + VP9_PREFIX=vp9/ + RC_RTC_SRCS += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) + RC_RTC_SRCS += $(VP9_PREFIX)vp9cx.mk RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.cc RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.h INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.cc INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.h endif +ifeq ($(CONFIG_VP8_ENCODER),yes) + VP8_PREFIX=vp8/ + RC_RTC_SRCS += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS)) + RC_RTC_SRCS += $(VP8_PREFIX)vp8_ratectrl_rtc.cc + RC_RTC_SRCS += $(VP8_PREFIX)vp8_ratectrl_rtc.h + INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP8_PREFIX)vp8_ratectrl_rtc.cc + INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP8_PREFIX)vp8_ratectrl_rtc.h +endif ifeq ($(CONFIG_VP9_DECODER),yes) VP9_PREFIX=vp9/ @@ -122,7 +139,7 @@ endif ifeq ($(CONFIG_MSVS),yes) CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd) GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd) -RC_RTC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vp9rcmt,vp9rcmd) +RC_RTC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxrcmt,vpxrcmd) # This variable uses deferred expansion intentionally, since the results of # $(wildcard) may change during the course of the Make. VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) @@ -228,6 +245,7 @@ vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def --ver=$(CONFIG_VS_VERSION) \ --src-path-bare="$(SRC_PATH_BARE)" \ --out=$@ $(CFLAGS) \ + --as=$(AS) \ $(filter $(SRC_PATH_BARE)/vp8/%.c, $(VCPROJ_SRCS)) \ $(filter $(SRC_PATH_BARE)/vp8/%.h, $(VCPROJ_SRCS)) \ $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \ @@ -244,20 +262,21 @@ PROJECTS-yes += vpx.$(VCPROJ_SFX) vpx.$(VCPROJ_SFX): vpx_config.asm vpx.$(VCPROJ_SFX): $(RTCD) -vp9rc.$(VCPROJ_SFX): \ +vpxrc.$(VCPROJ_SFX): \ VCPROJ_SRCS=$(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) -vp9rc.$(VCPROJ_SFX): $(RC_RTC_SRCS) +vpxrc.$(VCPROJ_SFX): $(RC_RTC_SRCS) @echo " [CREATE] $@" $(qexec)$(GEN_VCPROJ) \ $(if $(CONFIG_SHARED),--dll,--lib) \ --target=$(TOOLCHAIN) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ - --name=vp9rc \ + --name=vpxrc \ --proj-guid=C26FF952-9494-4838-9A3F-7F3D4F613385 \ --ver=$(CONFIG_VS_VERSION) \ --src-path-bare="$(SRC_PATH_BARE)" \ --out=$@ $(CFLAGS) \ + --as=$(AS) \ $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \ $(filter $(SRC_PATH_BARE)/vp9/%.cc, $(VCPROJ_SRCS)) \ $(filter $(SRC_PATH_BARE)/vp9/%.h, $(VCPROJ_SRCS)) \ @@ -269,10 +288,10 @@ vp9rc.$(VCPROJ_SFX): $(RC_RTC_SRCS) $(VCPROJ_SRCS)) \ --src-path-bare="$(SRC_PATH_BARE)" \ -PROJECTS-yes += vp9rc.$(VCPROJ_SFX) +PROJECTS-yes += vpxrc.$(VCPROJ_SFX) -vp9rc.$(VCPROJ_SFX): vpx_config.asm -vp9rc.$(VCPROJ_SFX): $(RTCD) +vpxrc.$(VCPROJ_SFX): vpx_config.asm +vpxrc.$(VCPROJ_SFX): $(RTCD) endif # ifeq ($(CONFIG_MSVS),yes) else # ifeq ($(CONFIG_EXTERNAL_BUILD),yes) @@ -281,8 +300,20 @@ OBJS-yes += $(LIBVPX_OBJS) LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) +# Updating version info. +# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info +# For libtool: c=, a=, r= +# libtool generates .so file as .so.[c-a].a.r, while -version-info c:r:a is +# passed to libtool. +# +# libvpx library file is generated as libvpx.so... +# MAJOR = c-a, MINOR = a, PATCH = r +# +# To determine SO_VERSION_{MAJOR,MINOR,PATCH}, calculate c,a,r with current +# SO_VERSION_* then follow the rules in the link to detemine the new version +# (c1, a1, r1) and set MAJOR to [c1-a1], MINOR to a1 and PATCH to r1 SO_VERSION_MAJOR := 6 -SO_VERSION_MINOR := 3 +SO_VERSION_MINOR := 4 SO_VERSION_PATCH := 0 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS)) LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib @@ -380,12 +411,11 @@ INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc CLEAN-OBJS += vpx.pc -ifeq ($(CONFIG_VP9_ENCODER),yes) - RC_RTC_OBJS=$(call objs,$(RC_RTC_SRCS)) +ifeq ($(CONFIG_ENCODERS),yes) RC_RTC_OBJS=$(call objs,$(RC_RTC_SRCS)) OBJS-yes += $(RC_RTC_OBJS) - LIBS-yes += $(BUILD_PFX)libvp9rc.a $(BUILD_PFX)libvp9rc_g.a - $(BUILD_PFX)libvp9rc_g.a: $(RC_RTC_OBJS) + LIBS-yes += $(BUILD_PFX)libvpxrc.a $(BUILD_PFX)libvpxrc_g.a + $(BUILD_PFX)libvpxrc_g.a: $(RC_RTC_OBJS) endif ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes) @@ -416,13 +446,13 @@ ifeq ($(VPX_ARCH_X86)$(VPX_ARCH_X86_64),yes) # YASM $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h @echo " [CREATE] $@" - @egrep "#define [A-Z0-9_]+ [01]" $< \ + @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \ | awk '{print $$2 " equ " $$3}' > $@ else ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION)) $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h @echo " [CREATE] $@" - @egrep "#define [A-Z0-9_]+ [01]" $< \ + @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \ | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@ @echo " END" $(ADS2GAS) >> $@ CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm @@ -475,10 +505,12 @@ TEST_INTRA_PRED_SPEED_SRCS=$(call addprefix_clean,test/,\ $(call enabled,TEST_INTRA_PRED_SPEED_SRCS)) TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS))) +ifeq ($(CONFIG_ENCODERS),yes) RC_INTERFACE_TEST_BIN=./test_rc_interface$(EXE_SFX) RC_INTERFACE_TEST_SRCS=$(call addprefix_clean,test/,\ $(call enabled,RC_INTERFACE_TEST_SRCS)) RC_INTERFACE_TEST_OBJS := $(sort $(call objs,$(RC_INTERFACE_TEST_SRCS))) +endif SIMPLE_ENCODE_TEST_BIN=./test_simple_encode$(EXE_SFX) SIMPLE_ENCODE_TEST_SRCS=$(call addprefix_clean,test/,\ @@ -532,6 +564,7 @@ gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.c --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \ --ver=$(CONFIG_VS_VERSION) \ --src-path-bare="$(SRC_PATH_BARE)" \ + --as=$(AS) \ -D_VARIADIC_MAX=10 \ --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \ -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src" @@ -548,6 +581,7 @@ test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_ --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ --ver=$(CONFIG_VS_VERSION) \ --src-path-bare="$(SRC_PATH_BARE)" \ + --as=$(AS) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ @@ -570,16 +604,18 @@ test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_ --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ --ver=$(CONFIG_VS_VERSION) \ --src-path-bare="$(SRC_PATH_BARE)" \ + --as=$(AS) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ endif # TEST_INTRA_PRED_SPEED +ifeq ($(CONFIG_ENCODERS),yes) ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),) PROJECTS-$(CONFIG_MSVS) += test_rc_interface.$(VCPROJ_SFX) test_rc_interface.$(VCPROJ_SFX): $(RC_INTERFACE_TEST_SRCS) vpx.$(VCPROJ_SFX) \ - vp9rc.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) + vpxrc.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) @echo " [CREATE] $@" $(qexec)$(GEN_VCPROJ) \ --exe \ @@ -588,12 +624,14 @@ test_rc_interface.$(VCPROJ_SFX): $(RC_INTERFACE_TEST_SRCS) vpx.$(VCPROJ_SFX) \ -D_VARIADIC_MAX=10 \ --proj-guid=30458F88-1BC6-4689-B41C-50F3737AAB27 \ --ver=$(CONFIG_VS_VERSION) \ + --as=$(AS) \ --src-path-bare="$(SRC_PATH_BARE)" \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ -L. -l$(CODEC_LIB) -l$(RC_RTC_LIB) -l$(GTEST_LIB) $^ endif # RC_INTERFACE_TEST +endif # CONFIG_VP9_ENCODER endif else @@ -635,17 +673,19 @@ $(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \ -L. -lvpx -lgtest $(extralibs) -lm)) endif # TEST_INTRA_PRED_SPEED +ifeq ($(CONFIG_ENCODERS),yes) ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),) $(RC_INTERFACE_TEST_OBJS) $(RC_INTERFACE_TEST_OBJS:.o=.d): \ CXXFLAGS += $(GTEST_INCLUDES) OBJS-yes += $(RC_INTERFACE_TEST_OBJS) BINS-yes += $(RC_INTERFACE_TEST_BIN) -$(RC_INTERFACE_TEST_BIN): $(TEST_LIBS) libvp9rc.a +$(RC_INTERFACE_TEST_BIN): $(TEST_LIBS) libvpxrc.a $(eval $(call linkerxx_template,$(RC_INTERFACE_TEST_BIN), \ $(RC_INTERFACE_TEST_OBJS) \ - -L. -lvpx -lgtest -lvp9rc $(extralibs) -lm)) + -L. -lvpx -lgtest -lvpxrc $(extralibs) -lm)) endif # RC_INTERFACE_TEST +endif # CONFIG_ENCODERS ifneq ($(strip $(SIMPLE_ENCODE_TEST_OBJS)),) $(SIMPLE_ENCODE_TEST_OBJS) $(SIMPLE_ENCODE_TEST_OBJS:.o=.d): \ diff --git a/third_party/libvpx/mainpage.dox b/third_party/libvpx/source/libvpx/mainpage.dox similarity index 100% rename from third_party/libvpx/mainpage.dox rename to third_party/libvpx/source/libvpx/mainpage.dox diff --git a/third_party/libvpx/md5_utils.c b/third_party/libvpx/source/libvpx/md5_utils.c similarity index 100% rename from third_party/libvpx/md5_utils.c rename to third_party/libvpx/source/libvpx/md5_utils.c diff --git a/third_party/libvpx/md5_utils.h b/third_party/libvpx/source/libvpx/md5_utils.h similarity index 100% rename from third_party/libvpx/md5_utils.h rename to third_party/libvpx/source/libvpx/md5_utils.h diff --git a/third_party/libvpx/rate_hist.c b/third_party/libvpx/source/libvpx/rate_hist.c similarity index 100% rename from third_party/libvpx/rate_hist.c rename to third_party/libvpx/source/libvpx/rate_hist.c diff --git a/third_party/libvpx/rate_hist.h b/third_party/libvpx/source/libvpx/rate_hist.h similarity index 100% rename from third_party/libvpx/rate_hist.h rename to third_party/libvpx/source/libvpx/rate_hist.h diff --git a/third_party/libvpx/solution.mk b/third_party/libvpx/source/libvpx/solution.mk similarity index 100% rename from third_party/libvpx/solution.mk rename to third_party/libvpx/source/libvpx/solution.mk diff --git a/third_party/libvpx/test/acm_random.h b/third_party/libvpx/source/libvpx/test/acm_random.h similarity index 100% rename from third_party/libvpx/test/acm_random.h rename to third_party/libvpx/source/libvpx/test/acm_random.h diff --git a/third_party/libvpx/test/active_map_refresh_test.cc b/third_party/libvpx/source/libvpx/test/active_map_refresh_test.cc similarity index 100% rename from third_party/libvpx/test/active_map_refresh_test.cc rename to third_party/libvpx/source/libvpx/test/active_map_refresh_test.cc diff --git a/third_party/libvpx/test/active_map_test.cc b/third_party/libvpx/source/libvpx/test/active_map_test.cc similarity index 100% rename from third_party/libvpx/test/active_map_test.cc rename to third_party/libvpx/source/libvpx/test/active_map_test.cc diff --git a/third_party/libvpx/test/add_noise_test.cc b/third_party/libvpx/source/libvpx/test/add_noise_test.cc similarity index 100% rename from third_party/libvpx/test/add_noise_test.cc rename to third_party/libvpx/source/libvpx/test/add_noise_test.cc diff --git a/third_party/libvpx/test/alt_ref_aq_segment_test.cc b/third_party/libvpx/source/libvpx/test/alt_ref_aq_segment_test.cc similarity index 100% rename from third_party/libvpx/test/alt_ref_aq_segment_test.cc rename to third_party/libvpx/source/libvpx/test/alt_ref_aq_segment_test.cc diff --git a/third_party/libvpx/test/altref_test.cc b/third_party/libvpx/source/libvpx/test/altref_test.cc similarity index 100% rename from third_party/libvpx/test/altref_test.cc rename to third_party/libvpx/source/libvpx/test/altref_test.cc diff --git a/third_party/libvpx/test/android/Android.mk b/third_party/libvpx/source/libvpx/test/android/Android.mk similarity index 100% rename from third_party/libvpx/test/android/Android.mk rename to third_party/libvpx/source/libvpx/test/android/Android.mk diff --git a/third_party/libvpx/test/android/README b/third_party/libvpx/source/libvpx/test/android/README similarity index 100% rename from third_party/libvpx/test/android/README rename to third_party/libvpx/source/libvpx/test/android/README diff --git a/third_party/libvpx/test/android/get_files.py b/third_party/libvpx/source/libvpx/test/android/get_files.py similarity index 100% rename from third_party/libvpx/test/android/get_files.py rename to third_party/libvpx/source/libvpx/test/android/get_files.py diff --git a/third_party/libvpx/test/android/scrape_gtest_log.py b/third_party/libvpx/source/libvpx/test/android/scrape_gtest_log.py similarity index 100% rename from third_party/libvpx/test/android/scrape_gtest_log.py rename to third_party/libvpx/source/libvpx/test/android/scrape_gtest_log.py diff --git a/third_party/libvpx/test/aq_segment_test.cc b/third_party/libvpx/source/libvpx/test/aq_segment_test.cc similarity index 100% rename from third_party/libvpx/test/aq_segment_test.cc rename to third_party/libvpx/source/libvpx/test/aq_segment_test.cc diff --git a/third_party/libvpx/test/avg_test.cc b/third_party/libvpx/source/libvpx/test/avg_test.cc similarity index 99% rename from third_party/libvpx/test/avg_test.cc rename to third_party/libvpx/source/libvpx/test/avg_test.cc index 4bc1944b1c66..196522ce588a 100644 --- a/third_party/libvpx/test/avg_test.cc +++ b/third_party/libvpx/source/libvpx/test/avg_test.cc @@ -202,6 +202,7 @@ class IntProRowTest : public AverageTestBase, int16_t *hbuf_asm_; int16_t *hbuf_c_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(IntProRowTest); typedef int16_t (*IntProColFunc)(uint8_t const *ref, const int width); @@ -228,6 +229,7 @@ class IntProColTest : public AverageTestBase, int16_t sum_asm_; int16_t sum_c_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(IntProColTest); #endif // HAVE_NEON || HAVE_SSE2 || HAVE_MSA typedef int (*SatdFunc)(const tran_low_t *coeffs, int length); diff --git a/third_party/libvpx/test/bench.cc b/third_party/libvpx/source/libvpx/test/bench.cc similarity index 100% rename from third_party/libvpx/test/bench.cc rename to third_party/libvpx/source/libvpx/test/bench.cc diff --git a/third_party/libvpx/test/bench.h b/third_party/libvpx/source/libvpx/test/bench.h similarity index 100% rename from third_party/libvpx/test/bench.h rename to third_party/libvpx/source/libvpx/test/bench.h diff --git a/third_party/libvpx/test/blockiness_test.cc b/third_party/libvpx/source/libvpx/test/blockiness_test.cc similarity index 100% rename from third_party/libvpx/test/blockiness_test.cc rename to third_party/libvpx/source/libvpx/test/blockiness_test.cc diff --git a/third_party/libvpx/test/borders_test.cc b/third_party/libvpx/source/libvpx/test/borders_test.cc similarity index 100% rename from third_party/libvpx/test/borders_test.cc rename to third_party/libvpx/source/libvpx/test/borders_test.cc diff --git a/third_party/libvpx/test/buffer.h b/third_party/libvpx/source/libvpx/test/buffer.h similarity index 100% rename from third_party/libvpx/test/buffer.h rename to third_party/libvpx/source/libvpx/test/buffer.h diff --git a/third_party/libvpx/test/byte_alignment_test.cc b/third_party/libvpx/source/libvpx/test/byte_alignment_test.cc similarity index 100% rename from third_party/libvpx/test/byte_alignment_test.cc rename to third_party/libvpx/source/libvpx/test/byte_alignment_test.cc diff --git a/third_party/libvpx/test/clear_system_state.h b/third_party/libvpx/source/libvpx/test/clear_system_state.h similarity index 100% rename from third_party/libvpx/test/clear_system_state.h rename to third_party/libvpx/source/libvpx/test/clear_system_state.h diff --git a/third_party/libvpx/test/codec_factory.h b/third_party/libvpx/source/libvpx/test/codec_factory.h similarity index 100% rename from third_party/libvpx/test/codec_factory.h rename to third_party/libvpx/source/libvpx/test/codec_factory.h diff --git a/third_party/libvpx/test/comp_avg_pred_test.cc b/third_party/libvpx/source/libvpx/test/comp_avg_pred_test.cc similarity index 100% rename from third_party/libvpx/test/comp_avg_pred_test.cc rename to third_party/libvpx/source/libvpx/test/comp_avg_pred_test.cc diff --git a/third_party/libvpx/test/config_test.cc b/third_party/libvpx/source/libvpx/test/config_test.cc similarity index 100% rename from third_party/libvpx/test/config_test.cc rename to third_party/libvpx/source/libvpx/test/config_test.cc diff --git a/third_party/libvpx/test/consistency_test.cc b/third_party/libvpx/source/libvpx/test/consistency_test.cc similarity index 100% rename from third_party/libvpx/test/consistency_test.cc rename to third_party/libvpx/source/libvpx/test/consistency_test.cc diff --git a/third_party/libvpx/test/convolve_test.cc b/third_party/libvpx/source/libvpx/test/convolve_test.cc similarity index 100% rename from third_party/libvpx/test/convolve_test.cc rename to third_party/libvpx/source/libvpx/test/convolve_test.cc diff --git a/third_party/libvpx/test/cpu_speed_test.cc b/third_party/libvpx/source/libvpx/test/cpu_speed_test.cc similarity index 100% rename from third_party/libvpx/test/cpu_speed_test.cc rename to third_party/libvpx/source/libvpx/test/cpu_speed_test.cc diff --git a/third_party/libvpx/test/cq_test.cc b/third_party/libvpx/source/libvpx/test/cq_test.cc similarity index 100% rename from third_party/libvpx/test/cq_test.cc rename to third_party/libvpx/source/libvpx/test/cq_test.cc diff --git a/third_party/libvpx/test/cx_set_ref.sh b/third_party/libvpx/source/libvpx/test/cx_set_ref.sh similarity index 100% rename from third_party/libvpx/test/cx_set_ref.sh rename to third_party/libvpx/source/libvpx/test/cx_set_ref.sh diff --git a/third_party/libvpx/test/dct16x16_test.cc b/third_party/libvpx/source/libvpx/test/dct16x16_test.cc similarity index 99% rename from third_party/libvpx/test/dct16x16_test.cc rename to third_party/libvpx/source/libvpx/test/dct16x16_test.cc index 321c66e4e922..c04880ec95f4 100644 --- a/third_party/libvpx/test/dct16x16_test.cc +++ b/third_party/libvpx/source/libvpx/test/dct16x16_test.cc @@ -740,6 +740,7 @@ class InvTrans16x16DCT : public Trans16x16TestBase, IdctFunc inv_txfm_; int thresh_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(InvTrans16x16DCT); TEST_P(InvTrans16x16DCT, CompareReference) { CompareInvReference(ref_txfm_, thresh_); diff --git a/third_party/libvpx/test/dct32x32_test.cc b/third_party/libvpx/source/libvpx/test/dct32x32_test.cc similarity index 100% rename from third_party/libvpx/test/dct32x32_test.cc rename to third_party/libvpx/source/libvpx/test/dct32x32_test.cc diff --git a/third_party/libvpx/test/dct_partial_test.cc b/third_party/libvpx/source/libvpx/test/dct_partial_test.cc similarity index 100% rename from third_party/libvpx/test/dct_partial_test.cc rename to third_party/libvpx/source/libvpx/test/dct_partial_test.cc diff --git a/third_party/libvpx/test/dct_test.cc b/third_party/libvpx/source/libvpx/test/dct_test.cc similarity index 100% rename from third_party/libvpx/test/dct_test.cc rename to third_party/libvpx/source/libvpx/test/dct_test.cc diff --git a/third_party/libvpx/test/decode_api_test.cc b/third_party/libvpx/source/libvpx/test/decode_api_test.cc similarity index 100% rename from third_party/libvpx/test/decode_api_test.cc rename to third_party/libvpx/source/libvpx/test/decode_api_test.cc diff --git a/third_party/libvpx/test/decode_corrupted.cc b/third_party/libvpx/source/libvpx/test/decode_corrupted.cc similarity index 100% rename from third_party/libvpx/test/decode_corrupted.cc rename to third_party/libvpx/source/libvpx/test/decode_corrupted.cc diff --git a/third_party/libvpx/test/decode_perf_test.cc b/third_party/libvpx/source/libvpx/test/decode_perf_test.cc similarity index 100% rename from third_party/libvpx/test/decode_perf_test.cc rename to third_party/libvpx/source/libvpx/test/decode_perf_test.cc diff --git a/third_party/libvpx/test/decode_svc_test.cc b/third_party/libvpx/source/libvpx/test/decode_svc_test.cc similarity index 100% rename from third_party/libvpx/test/decode_svc_test.cc rename to third_party/libvpx/source/libvpx/test/decode_svc_test.cc diff --git a/third_party/libvpx/test/decode_test_driver.cc b/third_party/libvpx/source/libvpx/test/decode_test_driver.cc similarity index 100% rename from third_party/libvpx/test/decode_test_driver.cc rename to third_party/libvpx/source/libvpx/test/decode_test_driver.cc diff --git a/third_party/libvpx/test/decode_test_driver.h b/third_party/libvpx/source/libvpx/test/decode_test_driver.h similarity index 100% rename from third_party/libvpx/test/decode_test_driver.h rename to third_party/libvpx/source/libvpx/test/decode_test_driver.h diff --git a/third_party/libvpx/test/decode_to_md5.sh b/third_party/libvpx/source/libvpx/test/decode_to_md5.sh similarity index 100% rename from third_party/libvpx/test/decode_to_md5.sh rename to third_party/libvpx/source/libvpx/test/decode_to_md5.sh diff --git a/third_party/libvpx/test/decode_with_drops.sh b/third_party/libvpx/source/libvpx/test/decode_with_drops.sh similarity index 100% rename from third_party/libvpx/test/decode_with_drops.sh rename to third_party/libvpx/source/libvpx/test/decode_with_drops.sh diff --git a/third_party/libvpx/test/encode_api_test.cc b/third_party/libvpx/source/libvpx/test/encode_api_test.cc similarity index 61% rename from third_party/libvpx/test/encode_api_test.cc rename to third_party/libvpx/source/libvpx/test/encode_api_test.cc index 6bd7e593dacc..dec19b226835 100644 --- a/third_party/libvpx/test/encode_api_test.cc +++ b/third_party/libvpx/source/libvpx/test/encode_api_test.cc @@ -8,6 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include + #include "third_party/googletest/src/include/gtest/gtest.h" #include "./vpx_config.h" @@ -18,6 +21,12 @@ namespace { #define NELEMENTS(x) static_cast(sizeof(x) / sizeof(x[0])) +bool IsVP9(const vpx_codec_iface_t *iface) { + static const char kVP9Name[] = "WebM Project VP9"; + return strncmp(kVP9Name, vpx_codec_iface_name(iface), sizeof(kVP9Name) - 1) == + 0; +} + TEST(EncodeAPI, InvalidParams) { static const vpx_codec_iface_t *kCodecs[] = { #if CONFIG_VP8_ENCODER @@ -184,10 +193,7 @@ TEST(EncodeAPI, MultiResEncode) { } // VP9 should report incapable, VP8 invalid for all configurations. - const char kVP9Name[] = "WebM Project VP9"; - const bool is_vp9 = strncmp(kVP9Name, vpx_codec_iface_name(iface), - sizeof(kVP9Name) - 1) == 0; - EXPECT_EQ(is_vp9 ? VPX_CODEC_INCAPABLE : VPX_CODEC_INVALID_PARAM, + EXPECT_EQ(IsVP9(iface) ? VPX_CODEC_INCAPABLE : VPX_CODEC_INVALID_PARAM, vpx_codec_enc_init_multi(&enc[0], iface, &cfg[0], 2, 0, &dsf[0])); for (int i = 0; i < 2; i++) { @@ -196,4 +202,112 @@ TEST(EncodeAPI, MultiResEncode) { } } +TEST(EncodeAPI, SetRoi) { + static struct { + const vpx_codec_iface_t *iface; + int ctrl_id; + } kCodecs[] = { +#if CONFIG_VP8_ENCODER + { &vpx_codec_vp8_cx_algo, VP8E_SET_ROI_MAP }, +#endif +#if CONFIG_VP9_ENCODER + { &vpx_codec_vp9_cx_algo, VP9E_SET_ROI_MAP }, +#endif + }; + constexpr int kWidth = 64; + constexpr int kHeight = 64; + + for (const auto &codec : kCodecs) { + SCOPED_TRACE(vpx_codec_iface_name(codec.iface)); + vpx_codec_ctx_t enc; + vpx_codec_enc_cfg_t cfg; + + EXPECT_EQ(vpx_codec_enc_config_default(codec.iface, &cfg, 0), VPX_CODEC_OK); + cfg.g_w = kWidth; + cfg.g_h = kHeight; + EXPECT_EQ(vpx_codec_enc_init(&enc, codec.iface, &cfg, 0), VPX_CODEC_OK); + + vpx_roi_map_t roi = {}; + uint8_t roi_map[kWidth * kHeight] = {}; + if (IsVP9(codec.iface)) { + roi.rows = (cfg.g_w + 7) >> 3; + roi.cols = (cfg.g_h + 7) >> 3; + } else { + roi.rows = (cfg.g_w + 15) >> 4; + roi.cols = (cfg.g_h + 15) >> 4; + } + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), VPX_CODEC_OK); + + roi.roi_map = roi_map; + // VP8 only. This value isn't range checked. + roi.static_threshold[1] = 1000; + roi.static_threshold[2] = INT_MIN; + roi.static_threshold[3] = INT_MAX; + + for (const auto delta : { -63, -1, 0, 1, 63 }) { + for (int i = 0; i < 8; ++i) { + roi.delta_q[i] = delta; + roi.delta_lf[i] = delta; + // VP9 only. + roi.skip[i] ^= 1; + roi.ref_frame[i] = (roi.ref_frame[i] + 1) % 4; + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), VPX_CODEC_OK); + } + } + + vpx_codec_err_t expected_error; + for (const auto delta : { -64, 64, INT_MIN, INT_MAX }) { + expected_error = VPX_CODEC_INVALID_PARAM; + for (int i = 0; i < 8; ++i) { + roi.delta_q[i] = delta; + // The max segment count for VP8 is 4, the remainder of the entries are + // ignored. + if (i >= 4 && !IsVP9(codec.iface)) expected_error = VPX_CODEC_OK; + + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), expected_error) + << "delta_q[" << i << "]: " << delta; + roi.delta_q[i] = 0; + + roi.delta_lf[i] = delta; + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), expected_error) + << "delta_lf[" << i << "]: " << delta; + roi.delta_lf[i] = 0; + } + } + + // VP8 should ignore skip[] and ref_frame[] values. + expected_error = + IsVP9(codec.iface) ? VPX_CODEC_INVALID_PARAM : VPX_CODEC_OK; + for (const auto skip : { -2, 2, INT_MIN, INT_MAX }) { + for (int i = 0; i < 8; ++i) { + roi.skip[i] = skip; + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), expected_error) + << "skip[" << i << "]: " << skip; + roi.skip[i] = 0; + } + } + + // VP9 allows negative values to be used to disable segmentation. + for (int ref_frame = -3; ref_frame < 0; ++ref_frame) { + for (int i = 0; i < 8; ++i) { + roi.ref_frame[i] = ref_frame; + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), VPX_CODEC_OK) + << "ref_frame[" << i << "]: " << ref_frame; + roi.ref_frame[i] = 0; + } + } + + for (const auto ref_frame : { 4, INT_MIN, INT_MAX }) { + for (int i = 0; i < 8; ++i) { + roi.ref_frame[i] = ref_frame; + EXPECT_EQ(vpx_codec_control_(&enc, codec.ctrl_id, &roi), expected_error) + << "ref_frame[" << i << "]: " << ref_frame; + roi.ref_frame[i] = 0; + } + } + + EXPECT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); + } +} + } // namespace diff --git a/third_party/libvpx/test/encode_perf_test.cc b/third_party/libvpx/source/libvpx/test/encode_perf_test.cc similarity index 100% rename from third_party/libvpx/test/encode_perf_test.cc rename to third_party/libvpx/source/libvpx/test/encode_perf_test.cc diff --git a/third_party/libvpx/test/encode_test_driver.cc b/third_party/libvpx/source/libvpx/test/encode_test_driver.cc similarity index 99% rename from third_party/libvpx/test/encode_test_driver.cc rename to third_party/libvpx/source/libvpx/test/encode_test_driver.cc index 6914804ec0fd..1ce39eaeffb4 100644 --- a/third_party/libvpx/test/encode_test_driver.cc +++ b/third_party/libvpx/source/libvpx/test/encode_test_driver.cc @@ -216,7 +216,7 @@ void EncoderTest::RunLoop(VideoSource *video) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: has_cxdata = true; - if (decoder.get() != nullptr && DoDecode()) { + if (decoder != nullptr && DoDecode()) { PreDecodeFrameHook(video, decoder.get()); vpx_codec_err_t res_dec = decoder->DecodeFrame( (const uint8_t *)pkt->data.frame.buf, pkt->data.frame.sz); diff --git a/third_party/libvpx/test/encode_test_driver.h b/third_party/libvpx/source/libvpx/test/encode_test_driver.h similarity index 97% rename from third_party/libvpx/test/encode_test_driver.h rename to third_party/libvpx/source/libvpx/test/encode_test_driver.h index 3edba4b926a5..38c61952eb87 100644 --- a/third_party/libvpx/test/encode_test_driver.h +++ b/third_party/libvpx/source/libvpx/test/encode_test_driver.h @@ -148,6 +148,13 @@ class Encoder { ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); } +#if CONFIG_VP9_ENCODER + void Control(int ctrl_id, vpx_rc_funcs_t *arg) { + const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg); + ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); + } +#endif // CONFIG_VP9_ENCODER + #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER void Control(int ctrl_id, vpx_active_map_t *arg) { const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg); diff --git a/third_party/libvpx/test/error_resilience_test.cc b/third_party/libvpx/source/libvpx/test/error_resilience_test.cc similarity index 100% rename from third_party/libvpx/test/error_resilience_test.cc rename to third_party/libvpx/source/libvpx/test/error_resilience_test.cc diff --git a/third_party/libvpx/test/examples.sh b/third_party/libvpx/source/libvpx/test/examples.sh similarity index 100% rename from third_party/libvpx/test/examples.sh rename to third_party/libvpx/source/libvpx/test/examples.sh diff --git a/third_party/libvpx/test/external_frame_buffer_test.cc b/third_party/libvpx/source/libvpx/test/external_frame_buffer_test.cc similarity index 100% rename from third_party/libvpx/test/external_frame_buffer_test.cc rename to third_party/libvpx/source/libvpx/test/external_frame_buffer_test.cc diff --git a/third_party/libvpx/test/fdct8x8_test.cc b/third_party/libvpx/source/libvpx/test/fdct8x8_test.cc similarity index 99% rename from third_party/libvpx/test/fdct8x8_test.cc rename to third_party/libvpx/source/libvpx/test/fdct8x8_test.cc index 770337da0003..0822666e706d 100644 --- a/third_party/libvpx/test/fdct8x8_test.cc +++ b/third_party/libvpx/source/libvpx/test/fdct8x8_test.cc @@ -625,6 +625,7 @@ class InvTrans8x8DCT : public FwdTrans8x8TestBase, IdctFunc inv_txfm_; int thresh_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(InvTrans8x8DCT); TEST_P(InvTrans8x8DCT, CompareReference) { CompareInvReference(ref_txfm_, thresh_); diff --git a/third_party/libvpx/test/frame_size_tests.cc b/third_party/libvpx/source/libvpx/test/frame_size_tests.cc similarity index 100% rename from third_party/libvpx/test/frame_size_tests.cc rename to third_party/libvpx/source/libvpx/test/frame_size_tests.cc diff --git a/third_party/libvpx/test/hadamard_test.cc b/third_party/libvpx/source/libvpx/test/hadamard_test.cc similarity index 100% rename from third_party/libvpx/test/hadamard_test.cc rename to third_party/libvpx/source/libvpx/test/hadamard_test.cc diff --git a/third_party/libvpx/test/i420_video_source.h b/third_party/libvpx/source/libvpx/test/i420_video_source.h similarity index 100% rename from third_party/libvpx/test/i420_video_source.h rename to third_party/libvpx/source/libvpx/test/i420_video_source.h diff --git a/third_party/libvpx/test/idct8x8_test.cc b/third_party/libvpx/source/libvpx/test/idct8x8_test.cc similarity index 100% rename from third_party/libvpx/test/idct8x8_test.cc rename to third_party/libvpx/source/libvpx/test/idct8x8_test.cc diff --git a/third_party/libvpx/test/idct_test.cc b/third_party/libvpx/source/libvpx/test/idct_test.cc similarity index 100% rename from third_party/libvpx/test/idct_test.cc rename to third_party/libvpx/source/libvpx/test/idct_test.cc diff --git a/third_party/libvpx/test/invalid_file_test.cc b/third_party/libvpx/source/libvpx/test/invalid_file_test.cc similarity index 100% rename from third_party/libvpx/test/invalid_file_test.cc rename to third_party/libvpx/source/libvpx/test/invalid_file_test.cc diff --git a/third_party/libvpx/test/ivf_video_source.h b/third_party/libvpx/source/libvpx/test/ivf_video_source.h similarity index 100% rename from third_party/libvpx/test/ivf_video_source.h rename to third_party/libvpx/source/libvpx/test/ivf_video_source.h diff --git a/third_party/libvpx/test/keyframe_test.cc b/third_party/libvpx/source/libvpx/test/keyframe_test.cc similarity index 100% rename from third_party/libvpx/test/keyframe_test.cc rename to third_party/libvpx/source/libvpx/test/keyframe_test.cc diff --git a/third_party/libvpx/test/level_test.cc b/third_party/libvpx/source/libvpx/test/level_test.cc similarity index 100% rename from third_party/libvpx/test/level_test.cc rename to third_party/libvpx/source/libvpx/test/level_test.cc diff --git a/third_party/libvpx/test/lpf_test.cc b/third_party/libvpx/source/libvpx/test/lpf_test.cc similarity index 99% rename from third_party/libvpx/test/lpf_test.cc rename to third_party/libvpx/source/libvpx/test/lpf_test.cc index 2c632a5a8cb6..62c6f30a0703 100644 --- a/third_party/libvpx/test/lpf_test.cc +++ b/third_party/libvpx/source/libvpx/test/lpf_test.cc @@ -145,6 +145,7 @@ class Loop8Test6Param : public ::testing::TestWithParam { loop_op_t loopfilter_op_; loop_op_t ref_loopfilter_op_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Loop8Test6Param); #if HAVE_NEON || HAVE_SSE2 || \ (HAVE_DSPR2 || HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH) @@ -166,6 +167,7 @@ class Loop8Test9Param : public ::testing::TestWithParam { dual_loop_op_t loopfilter_op_; dual_loop_op_t ref_loopfilter_op_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Loop8Test9Param); #endif // HAVE_NEON || HAVE_SSE2 || (HAVE_DSPR2 || HAVE_MSA && // (!CONFIG_VP9_HIGHBITDEPTH)) diff --git a/third_party/libvpx/test/md5_helper.h b/third_party/libvpx/source/libvpx/test/md5_helper.h similarity index 100% rename from third_party/libvpx/test/md5_helper.h rename to third_party/libvpx/source/libvpx/test/md5_helper.h diff --git a/third_party/libvpx/test/minmax_test.cc b/third_party/libvpx/source/libvpx/test/minmax_test.cc similarity index 100% rename from third_party/libvpx/test/minmax_test.cc rename to third_party/libvpx/source/libvpx/test/minmax_test.cc diff --git a/third_party/libvpx/test/non_greedy_mv_test.cc b/third_party/libvpx/source/libvpx/test/non_greedy_mv_test.cc similarity index 100% rename from third_party/libvpx/test/non_greedy_mv_test.cc rename to third_party/libvpx/source/libvpx/test/non_greedy_mv_test.cc diff --git a/third_party/libvpx/test/partial_idct_test.cc b/third_party/libvpx/source/libvpx/test/partial_idct_test.cc similarity index 100% rename from third_party/libvpx/test/partial_idct_test.cc rename to third_party/libvpx/source/libvpx/test/partial_idct_test.cc diff --git a/third_party/libvpx/test/postproc.sh b/third_party/libvpx/source/libvpx/test/postproc.sh similarity index 100% rename from third_party/libvpx/test/postproc.sh rename to third_party/libvpx/source/libvpx/test/postproc.sh diff --git a/third_party/libvpx/test/pp_filter_test.cc b/third_party/libvpx/source/libvpx/test/pp_filter_test.cc similarity index 100% rename from third_party/libvpx/test/pp_filter_test.cc rename to third_party/libvpx/source/libvpx/test/pp_filter_test.cc diff --git a/third_party/libvpx/test/predict_test.cc b/third_party/libvpx/source/libvpx/test/predict_test.cc similarity index 100% rename from third_party/libvpx/test/predict_test.cc rename to third_party/libvpx/source/libvpx/test/predict_test.cc diff --git a/third_party/libvpx/test/quantize_test.cc b/third_party/libvpx/source/libvpx/test/quantize_test.cc similarity index 99% rename from third_party/libvpx/test/quantize_test.cc rename to third_party/libvpx/source/libvpx/test/quantize_test.cc index b30b90f8f5d8..792b21432eb7 100644 --- a/third_party/libvpx/test/quantize_test.cc +++ b/third_party/libvpx/source/libvpx/test/quantize_test.cc @@ -146,6 +146,7 @@ class QuantizeTest : public QuantizeTestBase, VP8Quantize asm_quant_; VP8Quantize c_quant_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(QuantizeTest); TEST_P(QuantizeTest, TestZeroInput) { FillCoeffConstant(0); diff --git a/third_party/libvpx/test/realtime_test.cc b/third_party/libvpx/source/libvpx/test/realtime_test.cc similarity index 100% rename from third_party/libvpx/test/realtime_test.cc rename to third_party/libvpx/source/libvpx/test/realtime_test.cc diff --git a/third_party/libvpx/test/register_state_check.h b/third_party/libvpx/source/libvpx/test/register_state_check.h similarity index 100% rename from third_party/libvpx/test/register_state_check.h rename to third_party/libvpx/source/libvpx/test/register_state_check.h diff --git a/third_party/libvpx/test/resize_test.cc b/third_party/libvpx/source/libvpx/test/resize_test.cc similarity index 99% rename from third_party/libvpx/test/resize_test.cc rename to third_party/libvpx/source/libvpx/test/resize_test.cc index 65b94fa4f6fa..c57170ff9b78 100644 --- a/third_party/libvpx/test/resize_test.cc +++ b/third_party/libvpx/source/libvpx/test/resize_test.cc @@ -271,8 +271,8 @@ class ResizingVideoSource : public ::libvpx_test::DummyVideoSource { protected: virtual void Next() { ++frame_; - unsigned int width; - unsigned int height; + unsigned int width = 0; + unsigned int height = 0; ScaleForFrameNumber(frame_, kInitialWidth, kInitialHeight, &width, &height, flag_codec_, smaller_width_larger_size_); SetSize(width, height); diff --git a/third_party/libvpx/test/resize_util.sh b/third_party/libvpx/source/libvpx/test/resize_util.sh similarity index 100% rename from third_party/libvpx/test/resize_util.sh rename to third_party/libvpx/source/libvpx/test/resize_util.sh diff --git a/third_party/libvpx/test/sad_test.cc b/third_party/libvpx/source/libvpx/test/sad_test.cc similarity index 99% rename from third_party/libvpx/test/sad_test.cc rename to third_party/libvpx/source/libvpx/test/sad_test.cc index 34cb26ed11a6..ee10a4638914 100644 --- a/third_party/libvpx/test/sad_test.cc +++ b/third_party/libvpx/source/libvpx/test/sad_test.cc @@ -26,6 +26,10 @@ #include "vpx_ports/msvc.h" #include "vpx_ports/vpx_timer.h" +// const[expr] should be sufficient for DECLARE_ALIGNED but early +// implementations of c++11 appear to have some issues with it. +#define kDataAlignment 32 + template struct TestParams { TestParams(int w, int h, Function f, int bd = -1) @@ -117,9 +121,6 @@ class SADTestBase : public ::testing::TestWithParam { protected: // Handle blocks up to 4 blocks 64x64 with stride up to 128 // crbug.com/webm/1660 - // const[expr] should be sufficient for DECLARE_ALIGNED but early - // implementations of c++11 appear to have some issues with it. - enum { kDataAlignment = 32 }; static const int kDataBlockSize = 64 * 128; static const int kDataBufferSize = 4 * kDataBlockSize; diff --git a/third_party/libvpx/test/set_maps.sh b/third_party/libvpx/source/libvpx/test/set_maps.sh similarity index 100% rename from third_party/libvpx/test/set_maps.sh rename to third_party/libvpx/source/libvpx/test/set_maps.sh diff --git a/third_party/libvpx/test/set_roi.cc b/third_party/libvpx/source/libvpx/test/set_roi.cc similarity index 100% rename from third_party/libvpx/test/set_roi.cc rename to third_party/libvpx/source/libvpx/test/set_roi.cc diff --git a/third_party/libvpx/test/simple_decoder.sh b/third_party/libvpx/source/libvpx/test/simple_decoder.sh similarity index 100% rename from third_party/libvpx/test/simple_decoder.sh rename to third_party/libvpx/source/libvpx/test/simple_decoder.sh diff --git a/third_party/libvpx/test/simple_encode_test.cc b/third_party/libvpx/source/libvpx/test/simple_encode_test.cc similarity index 99% rename from third_party/libvpx/test/simple_encode_test.cc rename to third_party/libvpx/source/libvpx/test/simple_encode_test.cc index ab893045d803..03e28e338777 100644 --- a/third_party/libvpx/test/simple_encode_test.cc +++ b/third_party/libvpx/source/libvpx/test/simple_encode_test.cc @@ -13,6 +13,7 @@ #include #include #include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/video_source.h" #include "vp9/simple_encode.h" namespace vp9 { @@ -36,7 +37,8 @@ class SimpleEncodeTest : public ::testing::Test { const int frame_rate_den_ = 1; const int target_bitrate_ = 1000; const int num_frames_ = 17; - const std::string in_file_path_str_ = "bus_352x288_420_f20_b8.yuv"; + const std::string in_file_path_str_ = + libvpx_test::GetDataPath() + "/bus_352x288_420_f20_b8.yuv"; }; TEST_F(SimpleEncodeTest, ComputeFirstPassStats) { diff --git a/third_party/libvpx/test/simple_encoder.sh b/third_party/libvpx/source/libvpx/test/simple_encoder.sh similarity index 100% rename from third_party/libvpx/test/simple_encoder.sh rename to third_party/libvpx/source/libvpx/test/simple_encoder.sh diff --git a/third_party/libvpx/test/stress.sh b/third_party/libvpx/source/libvpx/test/stress.sh similarity index 100% rename from third_party/libvpx/test/stress.sh rename to third_party/libvpx/source/libvpx/test/stress.sh diff --git a/third_party/libvpx/test/sum_squares_test.cc b/third_party/libvpx/source/libvpx/test/sum_squares_test.cc similarity index 98% rename from third_party/libvpx/test/sum_squares_test.cc rename to third_party/libvpx/source/libvpx/test/sum_squares_test.cc index a47f5b5b1b67..df6da840376c 100644 --- a/third_party/libvpx/test/sum_squares_test.cc +++ b/third_party/libvpx/source/libvpx/test/sum_squares_test.cc @@ -45,6 +45,7 @@ class SumSquaresTest : public ::testing::TestWithParam { SSI16Func ref_func_; SSI16Func tst_func_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SumSquaresTest); TEST_P(SumSquaresTest, OperationCheck) { ACMRandom rnd(ACMRandom::DeterministicSeed()); diff --git a/third_party/libvpx/test/superframe_test.cc b/third_party/libvpx/source/libvpx/test/superframe_test.cc similarity index 100% rename from third_party/libvpx/test/superframe_test.cc rename to third_party/libvpx/source/libvpx/test/superframe_test.cc diff --git a/third_party/libvpx/test/svc_datarate_test.cc b/third_party/libvpx/source/libvpx/test/svc_datarate_test.cc similarity index 95% rename from third_party/libvpx/test/svc_datarate_test.cc rename to third_party/libvpx/source/libvpx/test/svc_datarate_test.cc index 0a7d0032c142..95d82ce54e5f 100644 --- a/third_party/libvpx/test/svc_datarate_test.cc +++ b/third_party/libvpx/source/libvpx/test/svc_datarate_test.cc @@ -84,6 +84,7 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { prev_frame_width[i] = 320; prev_frame_height[i] = 240; } + ksvc_flex_noupd_tlenh_ = false; } virtual void BeginPassHook(unsigned int /*pass*/) {} @@ -91,9 +92,10 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { // bypass/flexible mode. The pattern corresponds to the pattern // VP9E_TEMPORAL_LAYERING_MODE_0101 (temporal_layering_mode == 2) used in // non-flexible mode, except that we disable inter-layer prediction. - void set_frame_flags_bypass_mode( - int tl, int num_spatial_layers, int is_key_frame, - vpx_svc_ref_frame_config_t *ref_frame_config) { + void set_frame_flags_bypass_mode(int tl, int num_spatial_layers, + int is_key_frame, + vpx_svc_ref_frame_config_t *ref_frame_config, + int noupdate_tlenh) { for (int sl = 0; sl < num_spatial_layers; ++sl) ref_frame_config->update_buffer_slot[sl] = 0; @@ -151,9 +153,12 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { ref_frame_config->reference_last[sl] = 1; ref_frame_config->reference_golden[sl] = 0; ref_frame_config->reference_alt_ref[sl] = 0; - ref_frame_config->update_buffer_slot[sl] |= - 1 << ref_frame_config->alt_fb_idx[sl]; + // Non reference frame on top temporal top spatial. + ref_frame_config->update_buffer_slot[sl] = 0; } + // Force no update on all spatial layers for temporal enhancement layer + // frames. + if (noupdate_tlenh) ref_frame_config->update_buffer_slot[sl] = 0; } } } @@ -244,6 +249,22 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { } } + if (ksvc_flex_noupd_tlenh_) { + vpx_svc_layer_id_t layer_id; + layer_id.spatial_layer_id = 0; + layer_id.temporal_layer_id = (video->frame() % 2 != 0); + temporal_layer_id_ = layer_id.temporal_layer_id; + for (int i = 0; i < number_spatial_layers_; i++) { + layer_id.temporal_layer_id_per_spatial[i] = temporal_layer_id_; + ref_frame_config.duration[i] = 1; + } + encoder->Control(VP9E_SET_SVC_LAYER_ID, &layer_id); + set_frame_flags_bypass_mode(layer_id.temporal_layer_id, + number_spatial_layers_, 0, &ref_frame_config, + 1); + encoder->Control(VP9E_SET_SVC_REF_FRAME_CONFIG, &ref_frame_config); + } + if (update_pattern_ && video->frame() >= 100) { vpx_svc_layer_id_t layer_id; if (video->frame() == 100) { @@ -254,11 +275,14 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { layer_id.spatial_layer_id = 0; layer_id.temporal_layer_id = (video->frame() % 2 != 0); temporal_layer_id_ = layer_id.temporal_layer_id; - for (int i = 0; i < number_spatial_layers_; i++) + for (int i = 0; i < number_spatial_layers_; i++) { layer_id.temporal_layer_id_per_spatial[i] = temporal_layer_id_; + ref_frame_config.duration[i] = 1; + } encoder->Control(VP9E_SET_SVC_LAYER_ID, &layer_id); set_frame_flags_bypass_mode(layer_id.temporal_layer_id, - number_spatial_layers_, 0, &ref_frame_config); + number_spatial_layers_, 0, &ref_frame_config, + 0); encoder->Control(VP9E_SET_SVC_REF_FRAME_CONFIG, &ref_frame_config); } @@ -557,9 +581,14 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { } virtual void MismatchHook(const vpx_image_t *img1, const vpx_image_t *img2) { - double mismatch_psnr = compute_psnr(img1, img2); - mismatch_psnr_ += mismatch_psnr; - ++mismatch_nframes_; + // TODO(marpan): Look into why an assert is triggered in compute_psnr + // for mismatch frames for the special test case: ksvc_flex_noupd_tlenh. + // Has to do with dropped frames in bypass/flexible svc mode. + if (!ksvc_flex_noupd_tlenh_) { + double mismatch_psnr = compute_psnr(img1, img2); + mismatch_psnr_ += mismatch_psnr; + ++mismatch_nframes_; + } } unsigned int GetMismatchFrames() { return mismatch_nframes_; } @@ -604,6 +633,7 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { int num_resize_down_; unsigned int prev_frame_width[VPX_MAX_LAYERS]; unsigned int prev_frame_height[VPX_MAX_LAYERS]; + bool ksvc_flex_noupd_tlenh_; private: virtual void SetConfig(const int num_temporal_layer) { @@ -722,14 +752,14 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL2TLDynamicPatternChange) { cfg_.g_threads = 1; cfg_.rc_dropframe_thresh = 30; cfg_.kf_max_dist = 9999; - // Change SVC pattern on the fly. - update_pattern_ = 1; ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1, 0, 400); top_sl_width_ = 640; top_sl_height_ = 480; cfg_.rc_target_bitrate = 800; ResetModel(); + // Change SVC pattern on the fly. + update_pattern_ = 1; AssignLayerBitrates(); ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); CheckLayerRateTargeting(number_spatial_layers_, number_temporal_layers_, 0.78, @@ -1106,6 +1136,36 @@ TEST_P(DatarateOnePassCbrSvcFrameDropMultiBR, OnePassCbrSvc3SL3TL4Threads) { #endif } +// Check basic rate targeting for 1 pass CBR SVC: 3 spatial layers and +// 2 temporal layers, for KSVC in flexible mode with no update of reference +// frames for all spatial layers on TL > 0 superframes. +// Run HD clip with 4 threads. +TEST_P(DatarateOnePassCbrSvcFrameDropMultiBR, OnePassCbrSvc3SL2TL4ThKSVCFlex) { + SetSvcConfig(3, 2); + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 500; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 0; + cfg_.rc_max_quantizer = 63; + cfg_.g_threads = 4; + cfg_.rc_dropframe_thresh = 30; + cfg_.kf_max_dist = 9999; + ::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60); + top_sl_width_ = 1280; + top_sl_height_ = 720; + layer_framedrop_ = 0; + const int bitrates[3] = { 200, 400, 600 }; + cfg_.rc_target_bitrate = bitrates[GET_PARAM(3)]; + ResetModel(); + layer_framedrop_ = GET_PARAM(2); + AssignLayerBitrates(); + ksvc_flex_noupd_tlenh_ = true; + cfg_.temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + CheckLayerRateTargeting(number_spatial_layers_, number_temporal_layers_, 0.58, + 1.2); +} + // Params: speed setting, inter-layer prediction mode. class DatarateOnePassCbrSvcInterLayerPredSingleBR : public DatarateOnePassCbrSvc, diff --git a/third_party/libvpx/test/svc_end_to_end_test.cc b/third_party/libvpx/source/libvpx/test/svc_end_to_end_test.cc similarity index 75% rename from third_party/libvpx/test/svc_end_to_end_test.cc rename to third_party/libvpx/source/libvpx/test/svc_end_to_end_test.cc index edd4c887fccb..518824d03fc1 100644 --- a/third_party/libvpx/test/svc_end_to_end_test.cc +++ b/third_party/libvpx/source/libvpx/test/svc_end_to_end_test.cc @@ -121,7 +121,8 @@ class SyncFrameOnePassCbrSvc : public OnePassCbrSvc, frame_to_start_decode_(0), frame_to_sync_(0), inter_layer_pred_mode_(GET_PARAM(1)), decode_to_layer_before_sync_(-1), decode_to_layer_after_sync_(-1), denoiser_on_(0), - intra_only_test_(false), mismatch_nframes_(0), num_nonref_frames_(0) { + intra_only_test_(false), loopfilter_off_(0), mismatch_nframes_(0), + num_nonref_frames_(0) { SetMode(::libvpx_test::kRealTime); memset(&svc_layer_sync_, 0, sizeof(svc_layer_sync_)); } @@ -154,6 +155,8 @@ class SyncFrameOnePassCbrSvc : public OnePassCbrSvc, // So set it here in these tess to avoid encoder-decoder // mismatch check on color space setting. encoder->Control(VP9E_SET_COLOR_SPACE, VPX_CS_BT_601); + + encoder->Control(VP9E_SET_DISABLE_LOOPFILTER, loopfilter_off_); } if (video->frame() == frame_to_sync_) { encoder->Control(VP9E_SET_SVC_SPATIAL_LAYER_SYNC, &svc_layer_sync_); @@ -214,7 +217,10 @@ class SyncFrameOnePassCbrSvc : public OnePassCbrSvc, int decode_to_layer_after_sync_; int denoiser_on_; bool intra_only_test_; + int loopfilter_off_; vpx_svc_spatial_layer_sync_t svc_layer_sync_; + unsigned int mismatch_nframes_; + unsigned int num_nonref_frames_; private: virtual void SetConfig(const int num_temporal_layer) { @@ -243,9 +249,6 @@ class SyncFrameOnePassCbrSvc : public OnePassCbrSvc, cfg_.temporal_layering_mode = 1; } } - - unsigned int mismatch_nframes_; - unsigned int num_nonref_frames_; }; // Test for sync layer for 1 pass CBR SVC: 3 spatial layers and @@ -470,8 +473,176 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc1SL3TLSyncFrameIntraOnlyQVGA) { #endif } +// Params: Loopfilter modes. +class LoopfilterOnePassCbrSvc : public OnePassCbrSvc, + public ::libvpx_test::CodecTestWithParam { + public: + LoopfilterOnePassCbrSvc() + : OnePassCbrSvc(GET_PARAM(0)), loopfilter_off_(GET_PARAM(1)), + mismatch_nframes_(0), num_nonref_frames_(0) { + SetMode(::libvpx_test::kRealTime); + } + + protected: + virtual ~LoopfilterOnePassCbrSvc() {} + + virtual void SetUp() { + InitializeConfig(); + speed_setting_ = 7; + } + + virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, + ::libvpx_test::Encoder *encoder) { + PreEncodeFrameHookSetup(video, encoder); + if (number_temporal_layers_ > 1 || number_spatial_layers_ > 1) { + // Consider 3 cases: + if (loopfilter_off_ == 0) { + // loopfilter is on for all spatial layers on every superrframe. + for (int i = 0; i < VPX_SS_MAX_LAYERS; ++i) { + svc_params_.loopfilter_ctrl[i] = 0; + } + } else if (loopfilter_off_ == 1) { + // loopfilter is off for non-reference frames for all spatial layers. + for (int i = 0; i < VPX_SS_MAX_LAYERS; ++i) { + svc_params_.loopfilter_ctrl[i] = 1; + } + } else { + // loopfilter is off for all SL0 frames, and off only for non-reference + // frames for SL > 0. + svc_params_.loopfilter_ctrl[0] = 2; + for (int i = 1; i < VPX_SS_MAX_LAYERS; ++i) { + svc_params_.loopfilter_ctrl[i] = 1; + } + } + encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_); + } else if (number_temporal_layers_ == 1 && number_spatial_layers_ == 1) { + // For non-SVC mode use the single layer control. + encoder->Control(VP9E_SET_DISABLE_LOOPFILTER, loopfilter_off_); + } + } + + virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { + // Keep track of number of non-reference frames, needed for mismatch check. + // Non-reference frames are top spatial and temporal layer frames, + // for TL > 0. + if (temporal_layer_id_ == number_temporal_layers_ - 1 && + temporal_layer_id_ > 0 && + pkt->data.frame.spatial_layer_encoded[number_spatial_layers_ - 1]) + num_nonref_frames_++; + } + + virtual void MismatchHook(const vpx_image_t * /*img1*/, + const vpx_image_t * /*img2*/) { + ++mismatch_nframes_; + } + + virtual void SetConfig(const int /*num_temporal_layer*/) {} + + int GetMismatchFrames() const { return mismatch_nframes_; } + int GetNonRefFrames() const { return num_nonref_frames_; } + + int loopfilter_off_; + + private: + int mismatch_nframes_; + int num_nonref_frames_; +}; + +TEST_P(LoopfilterOnePassCbrSvc, OnePassCbrSvc1SL1TLLoopfilterOff) { + SetSvcConfig(1, 1); + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 500; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 0; + cfg_.rc_max_quantizer = 63; + cfg_.g_threads = 1; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_target_bitrate = 800; + cfg_.kf_max_dist = 9999; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 1; + cfg_.ts_rate_decimator[0] = 1; + cfg_.temporal_layering_mode = 0; + ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1, + 0, 400); + cfg_.rc_target_bitrate = 600; + AssignLayerBitrates(); + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +#if CONFIG_VP9_DECODER + if (loopfilter_off_ == 0) + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); + else + EXPECT_EQ(GetMismatchFrames(), 0); +#endif +} + +TEST_P(LoopfilterOnePassCbrSvc, OnePassCbrSvc1SL3TLLoopfilterOff) { + SetSvcConfig(1, 3); + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 500; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 0; + cfg_.rc_max_quantizer = 63; + cfg_.g_threads = 1; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_target_bitrate = 800; + cfg_.kf_max_dist = 9999; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 1; + cfg_.ts_rate_decimator[0] = 4; + cfg_.ts_rate_decimator[1] = 2; + cfg_.ts_rate_decimator[2] = 1; + cfg_.temporal_layering_mode = 3; + ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1, + 0, 400); + cfg_.rc_target_bitrate = 600; + AssignLayerBitrates(); + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +#if CONFIG_VP9_DECODER + if (loopfilter_off_ == 0) + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); + else + EXPECT_EQ(GetMismatchFrames(), 0); +#endif +} + +TEST_P(LoopfilterOnePassCbrSvc, OnePassCbrSvc3SL3TLLoopfilterOff) { + SetSvcConfig(3, 3); + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 500; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 0; + cfg_.rc_max_quantizer = 63; + cfg_.g_threads = 1; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_target_bitrate = 800; + cfg_.kf_max_dist = 9999; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 1; + cfg_.ts_rate_decimator[0] = 4; + cfg_.ts_rate_decimator[1] = 2; + cfg_.ts_rate_decimator[2] = 1; + cfg_.temporal_layering_mode = 3; + ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1, + 0, 400); + cfg_.rc_target_bitrate = 600; + AssignLayerBitrates(); + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +#if CONFIG_VP9_DECODER + if (loopfilter_off_ == 0) + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); + else + EXPECT_EQ(GetMismatchFrames(), 0); +#endif +} + VP9_INSTANTIATE_TEST_SUITE(SyncFrameOnePassCbrSvc, ::testing::Range(0, 3)); +VP9_INSTANTIATE_TEST_SUITE(LoopfilterOnePassCbrSvc, ::testing::Range(0, 3)); + INSTANTIATE_TEST_SUITE_P( VP9, ScalePartitionOnePassCbrSvc, ::testing::Values( diff --git a/third_party/libvpx/test/svc_test.cc b/third_party/libvpx/source/libvpx/test/svc_test.cc similarity index 93% rename from third_party/libvpx/test/svc_test.cc rename to third_party/libvpx/source/libvpx/test/svc_test.cc index 4798c7718323..cbc0abe032da 100644 --- a/third_party/libvpx/test/svc_test.cc +++ b/third_party/libvpx/source/libvpx/test/svc_test.cc @@ -43,13 +43,14 @@ void OnePassCbrSvc::PreEncodeFrameHookSetup(::libvpx_test::VideoSource *video, svc_params_.max_quantizers[i] = 63; svc_params_.min_quantizers[i] = 0; } - svc_params_.speed_per_layer[0] = base_speed_setting_; - for (int i = 1; i < VPX_SS_MAX_LAYERS; ++i) { - svc_params_.speed_per_layer[i] = speed_setting_; + if (number_temporal_layers_ > 1 || number_spatial_layers_ > 1) { + svc_params_.speed_per_layer[0] = base_speed_setting_; + for (int i = 1; i < VPX_SS_MAX_LAYERS; ++i) { + svc_params_.speed_per_layer[i] = speed_setting_; + } + encoder->Control(VP9E_SET_SVC, 1); + encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_); } - - encoder->Control(VP9E_SET_SVC, 1); - encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_); encoder->Control(VP8E_SET_CPUUSED, speed_setting_); encoder->Control(VP9E_SET_AQ_MODE, 3); encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 300); diff --git a/third_party/libvpx/test/svc_test.h b/third_party/libvpx/source/libvpx/test/svc_test.h similarity index 100% rename from third_party/libvpx/test/svc_test.h rename to third_party/libvpx/source/libvpx/test/svc_test.h diff --git a/third_party/libvpx/test/test-data.mk b/third_party/libvpx/source/libvpx/test/test-data.mk similarity index 99% rename from third_party/libvpx/test/test-data.mk rename to third_party/libvpx/source/libvpx/test/test-data.mk index ca2e11442ed1..46fe359898e1 100644 --- a/third_party/libvpx/test/test-data.mk +++ b/third_party/libvpx/source/libvpx/test/test-data.mk @@ -27,7 +27,7 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += noisy_clip_640_360.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rush_hour_444.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += screendata.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += niklas_640_480_30.yuv -LIBVPX_TEST_DATA-$(CONFIG_RATE_CTRL) += bus_352x288_420_f20_b8.yuv +LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += bus_352x288_420_f20_b8.yuv # Test vectors LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-001.ivf diff --git a/third_party/libvpx/test/test-data.sha1 b/third_party/libvpx/source/libvpx/test/test-data.sha1 similarity index 100% rename from third_party/libvpx/test/test-data.sha1 rename to third_party/libvpx/source/libvpx/test/test-data.sha1 diff --git a/third_party/libvpx/test/test.mk b/third_party/libvpx/source/libvpx/test/test.mk similarity index 94% rename from third_party/libvpx/test/test.mk rename to third_party/libvpx/source/libvpx/test/test.mk index c12fb786e745..41dfd5d83594 100644 --- a/third_party/libvpx/test/test.mk +++ b/third_party/libvpx/source/libvpx/test/test.mk @@ -58,6 +58,7 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_test.h LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_end_to_end_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += timestamp_test.cc +LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_ext_ratectrl_test.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.h @@ -192,10 +193,8 @@ LIBVPX_TEST_SRCS-$(CONFIG_NON_GREEDY_MV) += non_greedy_mv_test.cc endif ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_TEMPORAL_DENOISING),yesyes) -ifneq (, $(filter yes, $(HAVE_SSE2) $(HAVE_AVX2))) LIBVPX_TEST_SRCS-yes += vp9_denoiser_test.cc endif -endif LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_arf_freq_test.cc ifeq ($(CONFIG_VP9_ENCODER),yes) @@ -214,7 +213,14 @@ endif TEST_INTRA_PRED_SPEED_SRCS-yes := test_intra_pred_speed.cc TEST_INTRA_PRED_SPEED_SRCS-yes += ../md5_utils.h ../md5_utils.c -RC_INTERFACE_TEST_SRCS-$(CONFIG_VP9_ENCODER) := ratectrl_rtc_test.cc +RC_INTERFACE_TEST_SRCS-yes := test_rc_interface.cc +RC_INTERFACE_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_ratectrl_rtc_test.cc +RC_INTERFACE_TEST_SRCS-$(CONFIG_VP8_ENCODER) += vp8_ratectrl_rtc_test.cc +RC_INTERFACE_TEST_SRCS-$(CONFIG_ENCODERS) += encode_test_driver.cc +RC_INTERFACE_TEST_SRCS-$(CONFIG_ENCODERS) += encode_test_driver.h +RC_INTERFACE_TEST_SRCS-yes += decode_test_driver.cc +RC_INTERFACE_TEST_SRCS-yes += decode_test_driver.h +RC_INTERFACE_TEST_SRCS-yes += codec_factory.h endif # CONFIG_SHARED diff --git a/third_party/libvpx/test/test_intra_pred_speed.cc b/third_party/libvpx/source/libvpx/test/test_intra_pred_speed.cc similarity index 100% rename from third_party/libvpx/test/test_intra_pred_speed.cc rename to third_party/libvpx/source/libvpx/test/test_intra_pred_speed.cc diff --git a/third_party/libvpx/test/test_libvpx.cc b/third_party/libvpx/source/libvpx/test/test_libvpx.cc similarity index 100% rename from third_party/libvpx/test/test_libvpx.cc rename to third_party/libvpx/source/libvpx/test/test_libvpx.cc diff --git a/third_party/libvpx/source/libvpx/test/test_rc_interface.cc b/third_party/libvpx/source/libvpx/test/test_rc_interface.cc new file mode 100644 index 000000000000..ec75700f732f --- /dev/null +++ b/third_party/libvpx/source/libvpx/test/test_rc_interface.cc @@ -0,0 +1,6 @@ +#include "third_party/googletest/src/include/gtest/gtest.h" + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/third_party/libvpx/test/test_vector_test.cc b/third_party/libvpx/source/libvpx/test/test_vector_test.cc similarity index 100% rename from third_party/libvpx/test/test_vector_test.cc rename to third_party/libvpx/source/libvpx/test/test_vector_test.cc diff --git a/third_party/libvpx/test/test_vectors.cc b/third_party/libvpx/source/libvpx/test/test_vectors.cc similarity index 100% rename from third_party/libvpx/test/test_vectors.cc rename to third_party/libvpx/source/libvpx/test/test_vectors.cc diff --git a/third_party/libvpx/test/test_vectors.h b/third_party/libvpx/source/libvpx/test/test_vectors.h similarity index 100% rename from third_party/libvpx/test/test_vectors.h rename to third_party/libvpx/source/libvpx/test/test_vectors.h diff --git a/third_party/libvpx/test/tile_independence_test.cc b/third_party/libvpx/source/libvpx/test/tile_independence_test.cc similarity index 100% rename from third_party/libvpx/test/tile_independence_test.cc rename to third_party/libvpx/source/libvpx/test/tile_independence_test.cc diff --git a/third_party/libvpx/test/timestamp_test.cc b/third_party/libvpx/source/libvpx/test/timestamp_test.cc similarity index 100% rename from third_party/libvpx/test/timestamp_test.cc rename to third_party/libvpx/source/libvpx/test/timestamp_test.cc diff --git a/third_party/libvpx/test/tools_common.sh b/third_party/libvpx/source/libvpx/test/tools_common.sh similarity index 100% rename from third_party/libvpx/test/tools_common.sh rename to third_party/libvpx/source/libvpx/test/tools_common.sh diff --git a/third_party/libvpx/test/twopass_encoder.sh b/third_party/libvpx/source/libvpx/test/twopass_encoder.sh similarity index 100% rename from third_party/libvpx/test/twopass_encoder.sh rename to third_party/libvpx/source/libvpx/test/twopass_encoder.sh diff --git a/third_party/libvpx/test/user_priv_test.cc b/third_party/libvpx/source/libvpx/test/user_priv_test.cc similarity index 100% rename from third_party/libvpx/test/user_priv_test.cc rename to third_party/libvpx/source/libvpx/test/user_priv_test.cc diff --git a/third_party/libvpx/test/util.h b/third_party/libvpx/source/libvpx/test/util.h similarity index 100% rename from third_party/libvpx/test/util.h rename to third_party/libvpx/source/libvpx/test/util.h diff --git a/third_party/libvpx/test/variance_test.cc b/third_party/libvpx/source/libvpx/test/variance_test.cc similarity index 99% rename from third_party/libvpx/test/variance_test.cc rename to third_party/libvpx/source/libvpx/test/variance_test.cc index 72306d90c306..1b76b2041925 100644 --- a/third_party/libvpx/test/variance_test.cc +++ b/third_party/libvpx/source/libvpx/test/variance_test.cc @@ -840,6 +840,7 @@ INSTANTIATE_TEST_SUITE_P( MseParams(4, 4, &vpx_highbd_8_mse8x16_c), MseParams(4, 4, &vpx_highbd_8_mse8x8_c))); */ +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VpxHBDMseTest); INSTANTIATE_TEST_SUITE_P( C, VpxHBDVarianceTest, diff --git a/third_party/libvpx/test/video_source.h b/third_party/libvpx/source/libvpx/test/video_source.h similarity index 100% rename from third_party/libvpx/test/video_source.h rename to third_party/libvpx/source/libvpx/test/video_source.h diff --git a/third_party/libvpx/test/vp8_boolcoder_test.cc b/third_party/libvpx/source/libvpx/test/vp8_boolcoder_test.cc similarity index 100% rename from third_party/libvpx/test/vp8_boolcoder_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_boolcoder_test.cc diff --git a/third_party/libvpx/test/vp8_datarate_test.cc b/third_party/libvpx/source/libvpx/test/vp8_datarate_test.cc similarity index 100% rename from third_party/libvpx/test/vp8_datarate_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_datarate_test.cc diff --git a/third_party/libvpx/test/vp8_decrypt_test.cc b/third_party/libvpx/source/libvpx/test/vp8_decrypt_test.cc similarity index 100% rename from third_party/libvpx/test/vp8_decrypt_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_decrypt_test.cc diff --git a/third_party/libvpx/test/vp8_denoiser_sse2_test.cc b/third_party/libvpx/source/libvpx/test/vp8_denoiser_sse2_test.cc similarity index 92% rename from third_party/libvpx/test/vp8_denoiser_sse2_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_denoiser_sse2_test.cc index 0197f143f3e1..8cb84ddd8e87 100644 --- a/third_party/libvpx/test/vp8_denoiser_sse2_test.cc +++ b/third_party/libvpx/source/libvpx/test/vp8_denoiser_sse2_test.cc @@ -40,7 +40,12 @@ class VP8DenoiserTest : public ::testing::TestWithParam { int increase_denoising_; }; +// TODO(https://crbug.com/webm/1718): This test fails with gcc 8-10. +#if defined(__GNUC__) && __GNUC__ >= 8 +TEST_P(VP8DenoiserTest, DISABLED_BitexactCheck) { +#else TEST_P(VP8DenoiserTest, BitexactCheck) { +#endif ACMRandom rnd(ACMRandom::DeterministicSeed()); const int count_test_block = 4000; const int stride = 16; @@ -87,7 +92,7 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { // Check bitexactness. for (int h = 0; h < 16; ++h) { for (int w = 0; w < 16; ++w) { - EXPECT_EQ(avg_block_c[h * stride + w], avg_block_sse2[h * stride + w]); + ASSERT_EQ(avg_block_c[h * stride + w], avg_block_sse2[h * stride + w]); } } @@ -103,7 +108,7 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { // Check bitexactness. for (int h = 0; h < 16; ++h) { for (int w = 0; w < 16; ++w) { - EXPECT_EQ(avg_block_c[h * stride + w], avg_block_sse2[h * stride + w]); + ASSERT_EQ(avg_block_c[h * stride + w], avg_block_sse2[h * stride + w]); } } } diff --git a/third_party/libvpx/test/vp8_fdct4x4_test.cc b/third_party/libvpx/source/libvpx/test/vp8_fdct4x4_test.cc similarity index 100% rename from third_party/libvpx/test/vp8_fdct4x4_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_fdct4x4_test.cc diff --git a/third_party/libvpx/test/vp8_fragments_test.cc b/third_party/libvpx/source/libvpx/test/vp8_fragments_test.cc similarity index 100% rename from third_party/libvpx/test/vp8_fragments_test.cc rename to third_party/libvpx/source/libvpx/test/vp8_fragments_test.cc diff --git a/third_party/libvpx/test/vp8_multi_resolution_encoder.sh b/third_party/libvpx/source/libvpx/test/vp8_multi_resolution_encoder.sh similarity index 100% rename from third_party/libvpx/test/vp8_multi_resolution_encoder.sh rename to third_party/libvpx/source/libvpx/test/vp8_multi_resolution_encoder.sh diff --git a/third_party/libvpx/source/libvpx/test/vp8_ratectrl_rtc_test.cc b/third_party/libvpx/source/libvpx/test/vp8_ratectrl_rtc_test.cc new file mode 100644 index 000000000000..ad310666e7bb --- /dev/null +++ b/third_party/libvpx/source/libvpx/test/vp8_ratectrl_rtc_test.cc @@ -0,0 +1,343 @@ +/* + * Copyright (c) 2021 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include // NOLINT +#include + +#include "./vpx_config.h" +#include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/codec_factory.h" +#include "test/encode_test_driver.h" +#include "test/i420_video_source.h" +#include "test/util.h" +#include "test/video_source.h" +#include "vp8/vp8_ratectrl_rtc.h" +#include "vpx/vpx_codec.h" +#include "vpx_ports/bitops.h" + +namespace { + +struct Vp8RCTestVideo { + Vp8RCTestVideo() {} + Vp8RCTestVideo(const char *name_, int width_, int height_, + unsigned int frames_) + : name(name_), width(width_), height(height_), frames(frames_) {} + + friend std::ostream &operator<<(std::ostream &os, + const Vp8RCTestVideo &video) { + os << video.name << " " << video.width << " " << video.height << " " + << video.frames; + return os; + } + const char *name; + int width; + int height; + unsigned int frames; +}; + +const Vp8RCTestVideo kVp8RCTestVectors[] = { + Vp8RCTestVideo("niklas_640_480_30.yuv", 640, 480, 470), + Vp8RCTestVideo("desktop_office1.1280_720-020.yuv", 1280, 720, 300), +}; + +class Vp8RcInterfaceTest + : public ::libvpx_test::EncoderTest, + public ::libvpx_test::CodecTestWith2Params { + public: + Vp8RcInterfaceTest() + : EncoderTest(GET_PARAM(0)), key_interval_(3000), encoder_exit_(false) {} + virtual ~Vp8RcInterfaceTest() {} + + protected: + virtual void SetUp() { + InitializeConfig(); + SetMode(::libvpx_test::kRealTime); + } + + // From error_resilience_test.cc + int SetFrameFlags(int frame_num, int num_temp_layers) { + int frame_flags = 0; + if (num_temp_layers == 2) { + if (frame_num % 2 == 0) { + // Layer 0: predict from L and ARF, update L. + frame_flags = + VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF; + } else { + // Layer 1: predict from L, G and ARF, and update G. + frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST | + VP8_EFLAG_NO_UPD_ENTROPY; + } + } else if (num_temp_layers == 3) { + if (frame_num % 4 == 0) { + // Layer 0: predict from L, update L. + frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | + VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF; + } else if ((frame_num - 2) % 4 == 0) { + // Layer 1: predict from L, G, update G. + frame_flags = + VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_REF_ARF; + } else if ((frame_num - 1) % 2 == 0) { + // Layer 2: predict from L, G, ARF; update ARG. + frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST; + } + } + return frame_flags; + } + + int SetLayerId(int frame_num, int num_temp_layers) { + int layer_id = 0; + if (num_temp_layers == 2) { + if (frame_num % 2 == 0) { + layer_id = 0; + } else { + layer_id = 1; + } + } else if (num_temp_layers == 3) { + if (frame_num % 4 == 0) { + layer_id = 0; + } else if ((frame_num - 2) % 4 == 0) { + layer_id = 1; + } else if ((frame_num - 1) % 2 == 0) { + layer_id = 2; + } + } + return layer_id; + } + + virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, + ::libvpx_test::Encoder *encoder) { + if (rc_cfg_.ts_number_layers > 1) { + const int layer_id = SetLayerId(video->frame(), cfg_.ts_number_layers); + const int frame_flags = + SetFrameFlags(video->frame(), cfg_.ts_number_layers); + frame_params_.temporal_layer_id = layer_id; + if (video->frame() > 0) { + encoder->Control(VP8E_SET_TEMPORAL_LAYER_ID, layer_id); + encoder->Control(VP8E_SET_FRAME_FLAGS, frame_flags); + } + } else { + if (video->frame() == 0) { + encoder->Control(VP8E_SET_CPUUSED, -6); + encoder->Control(VP8E_SET_RTC_EXTERNAL_RATECTRL, 1); + encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 1000); + } + if (frame_params_.frame_type == INTER_FRAME) { + // Disable golden frame update. + frame_flags_ |= VP8_EFLAG_NO_UPD_GF; + frame_flags_ |= VP8_EFLAG_NO_UPD_ARF; + } + } + frame_params_.frame_type = + video->frame() % key_interval_ == 0 ? KEY_FRAME : INTER_FRAME; + encoder_exit_ = video->frame() == test_video_.frames; + } + + virtual void PostEncodeFrameHook(::libvpx_test::Encoder *encoder) { + if (encoder_exit_) { + return; + } + int qp; + encoder->Control(VP8E_GET_LAST_QUANTIZER, &qp); + rc_api_->ComputeQP(frame_params_); + ASSERT_EQ(rc_api_->GetQP(), qp); + } + + virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { + rc_api_->PostEncodeUpdate(pkt->data.frame.sz); + } + + void RunOneLayer() { + test_video_ = GET_PARAM(2); + target_bitrate_ = GET_PARAM(1); + if (test_video_.width == 1280 && target_bitrate_ == 200) return; + if (test_video_.width == 640 && target_bitrate_ == 1000) return; + SetConfig(); + rc_api_ = libvpx::VP8RateControlRTC::Create(rc_cfg_); + rc_api_->UpdateRateControl(rc_cfg_); + + ::libvpx_test::I420VideoSource video(test_video_.name, test_video_.width, + test_video_.height, 30, 1, 0, + test_video_.frames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + void RunPeriodicKey() { + test_video_ = GET_PARAM(2); + target_bitrate_ = GET_PARAM(1); + if (test_video_.width == 1280 && target_bitrate_ == 200) return; + if (test_video_.width == 640 && target_bitrate_ == 1000) return; + key_interval_ = 100; + SetConfig(); + rc_api_ = libvpx::VP8RateControlRTC::Create(rc_cfg_); + rc_api_->UpdateRateControl(rc_cfg_); + + ::libvpx_test::I420VideoSource video(test_video_.name, test_video_.width, + test_video_.height, 30, 1, 0, + test_video_.frames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + void RunTemporalLayers2TL() { + test_video_ = GET_PARAM(2); + target_bitrate_ = GET_PARAM(1); + if (test_video_.width == 1280 && target_bitrate_ == 200) return; + if (test_video_.width == 640 && target_bitrate_ == 1000) return; + SetConfigTemporalLayers(2); + rc_api_ = libvpx::VP8RateControlRTC::Create(rc_cfg_); + rc_api_->UpdateRateControl(rc_cfg_); + + ::libvpx_test::I420VideoSource video(test_video_.name, test_video_.width, + test_video_.height, 30, 1, 0, + test_video_.frames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + void RunTemporalLayers3TL() { + test_video_ = GET_PARAM(2); + target_bitrate_ = GET_PARAM(1); + if (test_video_.width == 1280 && target_bitrate_ == 200) return; + if (test_video_.width == 640 && target_bitrate_ == 1000) return; + SetConfigTemporalLayers(3); + rc_api_ = libvpx::VP8RateControlRTC::Create(rc_cfg_); + rc_api_->UpdateRateControl(rc_cfg_); + + ::libvpx_test::I420VideoSource video(test_video_.name, test_video_.width, + test_video_.height, 30, 1, 0, + test_video_.frames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + private: + void SetConfig() { + rc_cfg_.width = test_video_.width; + rc_cfg_.height = test_video_.height; + rc_cfg_.max_quantizer = 60; + rc_cfg_.min_quantizer = 2; + rc_cfg_.target_bandwidth = target_bitrate_; + rc_cfg_.buf_initial_sz = 600; + rc_cfg_.buf_optimal_sz = 600; + rc_cfg_.buf_sz = target_bitrate_; + rc_cfg_.undershoot_pct = 50; + rc_cfg_.overshoot_pct = 50; + rc_cfg_.max_intra_bitrate_pct = 1000; + rc_cfg_.framerate = 30.0; + rc_cfg_.layer_target_bitrate[0] = target_bitrate_; + + // Encoder settings for ground truth. + cfg_.g_w = test_video_.width; + cfg_.g_h = test_video_.height; + cfg_.rc_undershoot_pct = 50; + cfg_.rc_overshoot_pct = 50; + cfg_.rc_buf_initial_sz = 600; + cfg_.rc_buf_optimal_sz = 600; + cfg_.rc_buf_sz = target_bitrate_; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_min_quantizer = 2; + cfg_.rc_max_quantizer = 60; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 1; + cfg_.rc_target_bitrate = target_bitrate_; + cfg_.kf_min_dist = key_interval_; + cfg_.kf_max_dist = key_interval_; + } + + void SetConfigTemporalLayers(int temporal_layers) { + rc_cfg_.width = test_video_.width; + rc_cfg_.height = test_video_.height; + rc_cfg_.max_quantizer = 60; + rc_cfg_.min_quantizer = 2; + rc_cfg_.target_bandwidth = target_bitrate_; + rc_cfg_.buf_initial_sz = 600; + rc_cfg_.buf_optimal_sz = 600; + rc_cfg_.buf_sz = target_bitrate_; + rc_cfg_.undershoot_pct = 50; + rc_cfg_.overshoot_pct = 50; + rc_cfg_.max_intra_bitrate_pct = 1000; + rc_cfg_.framerate = 30.0; + if (temporal_layers == 2) { + rc_cfg_.layer_target_bitrate[0] = 60 * target_bitrate_ / 100; + rc_cfg_.layer_target_bitrate[1] = target_bitrate_; + rc_cfg_.ts_rate_decimator[0] = 2; + rc_cfg_.ts_rate_decimator[1] = 1; + } else if (temporal_layers == 3) { + rc_cfg_.layer_target_bitrate[0] = 40 * target_bitrate_ / 100; + rc_cfg_.layer_target_bitrate[1] = 60 * target_bitrate_ / 100; + rc_cfg_.layer_target_bitrate[2] = target_bitrate_; + rc_cfg_.ts_rate_decimator[0] = 4; + rc_cfg_.ts_rate_decimator[1] = 2; + rc_cfg_.ts_rate_decimator[2] = 1; + } + + rc_cfg_.ts_number_layers = temporal_layers; + + // Encoder settings for ground truth. + cfg_.g_w = test_video_.width; + cfg_.g_h = test_video_.height; + cfg_.rc_undershoot_pct = 50; + cfg_.rc_overshoot_pct = 50; + cfg_.rc_buf_initial_sz = 600; + cfg_.rc_buf_optimal_sz = 600; + cfg_.rc_buf_sz = target_bitrate_; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_min_quantizer = 2; + cfg_.rc_max_quantizer = 60; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 1; + cfg_.rc_target_bitrate = target_bitrate_; + cfg_.kf_min_dist = key_interval_; + cfg_.kf_max_dist = key_interval_; + // 2 Temporal layers, no spatial layers, CBR mode. + cfg_.ss_number_layers = 1; + cfg_.ts_number_layers = temporal_layers; + if (temporal_layers == 2) { + cfg_.ts_rate_decimator[0] = 2; + cfg_.ts_rate_decimator[1] = 1; + cfg_.ts_periodicity = 2; + cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100; + cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate; + } else if (temporal_layers == 3) { + cfg_.ts_rate_decimator[0] = 4; + cfg_.ts_rate_decimator[1] = 2; + cfg_.ts_rate_decimator[2] = 1; + cfg_.ts_periodicity = 4; + cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100; + cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100; + cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate; + } + } + + std::unique_ptr rc_api_; + libvpx::VP8RateControlRtcConfig rc_cfg_; + int key_interval_; + int target_bitrate_; + Vp8RCTestVideo test_video_; + libvpx::VP8FrameParamsQpRTC frame_params_; + bool encoder_exit_; +}; + +TEST_P(Vp8RcInterfaceTest, OneLayer) { RunOneLayer(); } + +TEST_P(Vp8RcInterfaceTest, OneLayerPeriodicKey) { RunPeriodicKey(); } + +TEST_P(Vp8RcInterfaceTest, TemporalLayers2TL) { RunTemporalLayers2TL(); } + +TEST_P(Vp8RcInterfaceTest, TemporalLayers3TL) { RunTemporalLayers3TL(); } + +VP8_INSTANTIATE_TEST_SUITE(Vp8RcInterfaceTest, + ::testing::Values(200, 400, 1000), + ::testing::ValuesIn(kVp8RCTestVectors)); + +} // namespace diff --git a/third_party/libvpx/test/vp9_arf_freq_test.cc b/third_party/libvpx/source/libvpx/test/vp9_arf_freq_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_arf_freq_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_arf_freq_test.cc diff --git a/third_party/libvpx/test/vp9_block_error_test.cc b/third_party/libvpx/source/libvpx/test/vp9_block_error_test.cc similarity index 99% rename from third_party/libvpx/test/vp9_block_error_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_block_error_test.cc index dc1ff49c68cb..b93b014e652a 100644 --- a/third_party/libvpx/test/vp9_block_error_test.cc +++ b/third_party/libvpx/source/libvpx/test/vp9_block_error_test.cc @@ -67,6 +67,7 @@ class BlockErrorTest : public ::testing::TestWithParam { HBDBlockErrorFunc error_block_op_; HBDBlockErrorFunc ref_error_block_op_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BlockErrorTest); TEST_P(BlockErrorTest, OperationCheck) { ACMRandom rnd(ACMRandom::DeterministicSeed()); diff --git a/third_party/libvpx/test/vp9_boolcoder_test.cc b/third_party/libvpx/source/libvpx/test/vp9_boolcoder_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_boolcoder_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_boolcoder_test.cc diff --git a/third_party/libvpx/test/vp9_datarate_test.cc b/third_party/libvpx/source/libvpx/test/vp9_datarate_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_datarate_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_datarate_test.cc diff --git a/third_party/libvpx/test/vp9_decrypt_test.cc b/third_party/libvpx/source/libvpx/test/vp9_decrypt_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_decrypt_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_decrypt_test.cc diff --git a/third_party/libvpx/test/vp9_denoiser_test.cc b/third_party/libvpx/source/libvpx/test/vp9_denoiser_test.cc similarity index 98% rename from third_party/libvpx/test/vp9_denoiser_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_denoiser_test.cc index 3d76edfaa226..d884b7eb9258 100644 --- a/third_party/libvpx/test/vp9_denoiser_test.cc +++ b/third_party/libvpx/source/libvpx/test/vp9_denoiser_test.cc @@ -51,6 +51,7 @@ class VP9DenoiserTest protected: BLOCK_SIZE bs_; }; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VP9DenoiserTest); TEST_P(VP9DenoiserTest, BitexactCheck) { ACMRandom rnd(ACMRandom::DeterministicSeed()); diff --git a/third_party/libvpx/test/vp9_encoder_parms_get_to_decoder.cc b/third_party/libvpx/source/libvpx/test/vp9_encoder_parms_get_to_decoder.cc similarity index 100% rename from third_party/libvpx/test/vp9_encoder_parms_get_to_decoder.cc rename to third_party/libvpx/source/libvpx/test/vp9_encoder_parms_get_to_decoder.cc diff --git a/third_party/libvpx/test/vp9_end_to_end_test.cc b/third_party/libvpx/source/libvpx/test/vp9_end_to_end_test.cc similarity index 98% rename from third_party/libvpx/test/vp9_end_to_end_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_end_to_end_test.cc index 4e3a78fac4b6..7a85db26a4c4 100644 --- a/third_party/libvpx/test/vp9_end_to_end_test.cc +++ b/third_party/libvpx/source/libvpx/test/vp9_end_to_end_test.cc @@ -31,7 +31,7 @@ const double kPsnrThreshold[][5] = { { 36.0, 37.0, 37.0, 37.0, 37.0 }, { 35.0, 36.0, 36.0, 36.0, 36.0 }, { 34.0, 35.0, 35.0, 35.0, 35.0 }, { 33.0, 34.0, 34.0, 34.0, 34.0 }, { 32.0, 33.0, 33.0, 33.0, 33.0 }, { 28.0, 32.0, 32.0, 32.0, 32.0 }, - { 28.5, 31.0, 31.0, 31.0, 31.0 }, { 27.5, 30.0, 30.0, 30.0, 30.0 }, + { 28.4, 31.0, 31.0, 31.0, 31.0 }, { 27.5, 30.0, 30.0, 30.0, 30.0 }, }; typedef struct { @@ -342,7 +342,7 @@ VP9_INSTANTIATE_TEST_SUITE(EndToEndTestLarge, VP9_INSTANTIATE_TEST_SUITE(EndToEndNV12, ::testing::Values(::libvpx_test::kRealTime), ::testing::ValuesIn(kTestVectorsNv12), - ::testing::ValuesIn({ 6, 7, 8 })); + ::testing::Values(6, 7, 8)); VP9_INSTANTIATE_TEST_SUITE(EndToEndTestAdaptiveRDThresh, ::testing::Values(5, 6, 7), ::testing::Values(8, 9)); diff --git a/third_party/libvpx/test/vp9_ethread_test.cc b/third_party/libvpx/source/libvpx/test/vp9_ethread_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_ethread_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_ethread_test.cc diff --git a/third_party/libvpx/source/libvpx/test/vp9_ext_ratectrl_test.cc b/third_party/libvpx/source/libvpx/test/vp9_ext_ratectrl_test.cc new file mode 100644 index 000000000000..60a350b84ec3 --- /dev/null +++ b/third_party/libvpx/source/libvpx/test/vp9_ext_ratectrl_test.cc @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include + +#include "test/codec_factory.h" +#include "test/encode_test_driver.h" +#include "test/util.h" +#include "test/yuv_video_source.h" +#include "third_party/googletest/src/include/gtest/gtest.h" +#include "vpx/vpx_ext_ratectrl.h" + +namespace { + +constexpr int kModelMagicNumber = 51396; +constexpr uintptr_t PrivMagicNumber = 5566; +constexpr int kFrameNum = 5; +constexpr int kLosslessCodingIndex = 2; + +struct ToyRateCtrl { + int magic_number; + int coding_index; +}; + +vpx_rc_status_t rc_create_model(void *priv, + const vpx_rc_config_t *ratectrl_config, + vpx_rc_model_t *rate_ctrl_model_pt) { + ToyRateCtrl *toy_rate_ctrl = new (std::nothrow) ToyRateCtrl; + EXPECT_NE(toy_rate_ctrl, nullptr); + toy_rate_ctrl->magic_number = kModelMagicNumber; + toy_rate_ctrl->coding_index = -1; + *rate_ctrl_model_pt = toy_rate_ctrl; + EXPECT_EQ(priv, reinterpret_cast(PrivMagicNumber)); + EXPECT_EQ(ratectrl_config->frame_width, 352); + EXPECT_EQ(ratectrl_config->frame_height, 288); + EXPECT_EQ(ratectrl_config->show_frame_count, kFrameNum); + EXPECT_EQ(ratectrl_config->target_bitrate_kbps, 24000); + EXPECT_EQ(ratectrl_config->frame_rate_num, 30); + EXPECT_EQ(ratectrl_config->frame_rate_den, 1); + return VPX_RC_OK; +} + +vpx_rc_status_t rc_send_firstpass_stats( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_firstpass_stats_t *first_pass_stats) { + const ToyRateCtrl *toy_rate_ctrl = + static_cast(rate_ctrl_model); + EXPECT_EQ(toy_rate_ctrl->magic_number, kModelMagicNumber); + EXPECT_EQ(first_pass_stats->num_frames, kFrameNum); + for (int i = 0; i < first_pass_stats->num_frames; ++i) { + EXPECT_DOUBLE_EQ(first_pass_stats->frame_stats[i].frame, i); + } + return VPX_RC_OK; +} + +vpx_rc_status_t rc_get_encodeframe_decision( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_encodeframe_info_t *encode_frame_info, + vpx_rc_encodeframe_decision_t *frame_decision) { + ToyRateCtrl *toy_rate_ctrl = static_cast(rate_ctrl_model); + toy_rate_ctrl->coding_index += 1; + + EXPECT_EQ(toy_rate_ctrl->magic_number, kModelMagicNumber); + + EXPECT_LT(encode_frame_info->show_index, kFrameNum); + EXPECT_EQ(encode_frame_info->coding_index, toy_rate_ctrl->coding_index); + + if (encode_frame_info->coding_index == 0) { + EXPECT_EQ(encode_frame_info->show_index, 0); + EXPECT_EQ(encode_frame_info->gop_index, 0); + EXPECT_EQ(encode_frame_info->frame_type, 0 /*kFrameTypeKey*/); + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0], + 0); // kRefFrameTypeLast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[1], + 0); // kRefFrameTypePast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[2], + 0); // kRefFrameTypeFuture + } + + if (encode_frame_info->coding_index == 1) { + EXPECT_EQ(encode_frame_info->show_index, 4); + EXPECT_EQ(encode_frame_info->gop_index, 1); + EXPECT_EQ(encode_frame_info->frame_type, 2 /*kFrameTypeAltRef*/); + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0], + 1); // kRefFrameTypeLast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[1], + 0); // kRefFrameTypePast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[2], + 0); // kRefFrameTypeFuture + EXPECT_EQ(encode_frame_info->ref_frame_coding_indexes[0], + 0); // kRefFrameTypeLast + } + + if (encode_frame_info->coding_index >= 2 && + encode_frame_info->coding_index < 5) { + // In the first group of pictures, coding_index and gop_index are equal. + EXPECT_EQ(encode_frame_info->gop_index, encode_frame_info->coding_index); + EXPECT_EQ(encode_frame_info->frame_type, 1 /*kFrameTypeInter*/); + } + + if (encode_frame_info->coding_index == 5) { + EXPECT_EQ(encode_frame_info->show_index, 4); + EXPECT_EQ(encode_frame_info->gop_index, 0); + EXPECT_EQ(encode_frame_info->frame_type, 3 /*kFrameTypeOverlay*/); + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0], + 1); // kRefFrameTypeLast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[1], + 1); // kRefFrameTypePast + EXPECT_EQ(encode_frame_info->ref_frame_valid_list[2], + 1); // kRefFrameTypeFuture + EXPECT_EQ(encode_frame_info->ref_frame_coding_indexes[0], + 4); // kRefFrameTypeLast + EXPECT_EQ(encode_frame_info->ref_frame_coding_indexes[1], + 0); // kRefFrameTypePast + EXPECT_EQ(encode_frame_info->ref_frame_coding_indexes[2], + 1); // kRefFrameTypeFuture + } + if (encode_frame_info->coding_index == kLosslessCodingIndex) { + // We should get sse == 0 at rc_update_encodeframe_result() + frame_decision->q_index = 0; + } else { + frame_decision->q_index = 100; + } + frame_decision->max_frame_size = 0; + return VPX_RC_OK; +} + +vpx_rc_status_t rc_update_encodeframe_result( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_encodeframe_result_t *encode_frame_result) { + const ToyRateCtrl *toy_rate_ctrl = + static_cast(rate_ctrl_model); + EXPECT_EQ(toy_rate_ctrl->magic_number, kModelMagicNumber); + + const int64_t ref_pixel_count = 352 * 288 * 3 / 2; + EXPECT_EQ(encode_frame_result->pixel_count, ref_pixel_count); + if (toy_rate_ctrl->coding_index == kLosslessCodingIndex) { + EXPECT_EQ(encode_frame_result->sse, 0); + } + if (toy_rate_ctrl->coding_index == kLosslessCodingIndex) { + EXPECT_EQ(encode_frame_result->actual_encoding_qindex, 0); + } else { + EXPECT_EQ(encode_frame_result->actual_encoding_qindex, 100); + } + return VPX_RC_OK; +} + +vpx_rc_status_t rc_delete_model(vpx_rc_model_t rate_ctrl_model) { + ToyRateCtrl *toy_rate_ctrl = static_cast(rate_ctrl_model); + EXPECT_EQ(toy_rate_ctrl->magic_number, kModelMagicNumber); + delete toy_rate_ctrl; + return VPX_RC_OK; +} + +class ExtRateCtrlTest : public ::libvpx_test::EncoderTest, + public ::testing::Test { + protected: + ExtRateCtrlTest() : EncoderTest(&::libvpx_test::kVP9) {} + + ~ExtRateCtrlTest() override = default; + + void SetUp() override { + InitializeConfig(); + SetMode(::libvpx_test::kTwoPassGood); + } + + void PreEncodeFrameHook(::libvpx_test::VideoSource *video, + ::libvpx_test::Encoder *encoder) override { + if (video->frame() == 0) { + vpx_rc_funcs_t rc_funcs; + rc_funcs.create_model = rc_create_model; + rc_funcs.send_firstpass_stats = rc_send_firstpass_stats; + rc_funcs.get_encodeframe_decision = rc_get_encodeframe_decision; + rc_funcs.update_encodeframe_result = rc_update_encodeframe_result; + rc_funcs.delete_model = rc_delete_model; + rc_funcs.priv = reinterpret_cast(PrivMagicNumber); + encoder->Control(VP9E_SET_EXTERNAL_RATE_CONTROL, &rc_funcs); + } + } +}; + +TEST_F(ExtRateCtrlTest, EncodeTest) { + cfg_.rc_target_bitrate = 24000; + + std::unique_ptr video; + video.reset(new (std::nothrow) libvpx_test::YUVVideoSource( + "bus_352x288_420_f20_b8.yuv", VPX_IMG_FMT_I420, 352, 288, 30, 1, 0, + kFrameNum)); + + ASSERT_NE(video.get(), nullptr); + ASSERT_NO_FATAL_FAILURE(RunLoop(video.get())); +} + +} // namespace diff --git a/third_party/libvpx/test/vp9_intrapred_test.cc b/third_party/libvpx/source/libvpx/test/vp9_intrapred_test.cc similarity index 99% rename from third_party/libvpx/test/vp9_intrapred_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_intrapred_test.cc index fdcccd5c22f8..ccace719ea7d 100644 --- a/third_party/libvpx/test/vp9_intrapred_test.cc +++ b/third_party/libvpx/source/libvpx/test/vp9_intrapred_test.cc @@ -468,6 +468,8 @@ void IntraPredTest::Predict() { } typedef IntraPredTest VP9HighbdIntraPredTest; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VP9HighbdIntraPredTest); + TEST_P(VP9HighbdIntraPredTest, HighbdIntraPredTests) { // max block size is 32 DECLARE_ALIGNED(16, uint16_t, left_col[2 * 32]); diff --git a/third_party/libvpx/test/vp9_lossless_test.cc b/third_party/libvpx/source/libvpx/test/vp9_lossless_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_lossless_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_lossless_test.cc diff --git a/third_party/libvpx/test/vp9_motion_vector_test.cc b/third_party/libvpx/source/libvpx/test/vp9_motion_vector_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_motion_vector_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_motion_vector_test.cc diff --git a/third_party/libvpx/test/vp9_quantize_test.cc b/third_party/libvpx/source/libvpx/test/vp9_quantize_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_quantize_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_quantize_test.cc diff --git a/third_party/libvpx/source/libvpx/test/vp9_ratectrl_rtc_test.cc b/third_party/libvpx/source/libvpx/test/vp9_ratectrl_rtc_test.cc new file mode 100644 index 000000000000..b09a45bb76bf --- /dev/null +++ b/third_party/libvpx/source/libvpx/test/vp9_ratectrl_rtc_test.cc @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include "vp9/ratectrl_rtc.h" + +#include // NOLINT +#include + +#include "./vpx_config.h" +#include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/codec_factory.h" +#include "test/encode_test_driver.h" +#include "test/i420_video_source.h" +#include "test/util.h" +#include "test/video_source.h" +#include "vpx/vpx_codec.h" +#include "vpx_ports/bitops.h" + +namespace { + +const size_t kNumFrames = 300; + +const int kTemporalId[4] = { 0, 2, 1, 2 }; + +class RcInterfaceTest + : public ::libvpx_test::EncoderTest, + public ::libvpx_test::CodecTestWith2Params { + public: + RcInterfaceTest() + : EncoderTest(GET_PARAM(0)), aq_mode_(GET_PARAM(1)), key_interval_(3000), + encoder_exit_(false) {} + + virtual ~RcInterfaceTest() {} + + protected: + virtual void SetUp() { + InitializeConfig(); + SetMode(::libvpx_test::kRealTime); + } + + virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video, + libvpx_test::Encoder *encoder) { + if (video->frame() == 0) { + encoder->Control(VP8E_SET_CPUUSED, 7); + encoder->Control(VP9E_SET_AQ_MODE, aq_mode_); + encoder->Control(VP9E_SET_TUNE_CONTENT, 0); + encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 1000); + encoder->Control(VP9E_SET_RTC_EXTERNAL_RATECTRL, 1); + } + frame_params_.frame_type = + video->frame() % key_interval_ == 0 ? KEY_FRAME : INTER_FRAME; + if (rc_cfg_.rc_mode == VPX_CBR && frame_params_.frame_type == INTER_FRAME) { + // Disable golden frame update. + frame_flags_ |= VP8_EFLAG_NO_UPD_GF; + frame_flags_ |= VP8_EFLAG_NO_UPD_ARF; + } + encoder_exit_ = video->frame() == kNumFrames; + } + + virtual void PostEncodeFrameHook(::libvpx_test::Encoder *encoder) { + if (encoder_exit_) { + return; + } + int loopfilter_level, qp; + encoder->Control(VP9E_GET_LOOPFILTER_LEVEL, &loopfilter_level); + encoder->Control(VP8E_GET_LAST_QUANTIZER, &qp); + rc_api_->ComputeQP(frame_params_); + ASSERT_EQ(rc_api_->GetQP(), qp); + ASSERT_EQ(rc_api_->GetLoopfilterLevel(), loopfilter_level); + } + + virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { + rc_api_->PostEncodeUpdate(pkt->data.frame.sz); + } + + void RunOneLayer() { + SetConfig(GET_PARAM(2)); + rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); + frame_params_.spatial_layer_id = 0; + frame_params_.temporal_layer_id = 0; + + ::libvpx_test::I420VideoSource video("desktop_office1.1280_720-020.yuv", + 1280, 720, 30, 1, 0, kNumFrames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + void RunOneLayerVBRPeriodicKey() { + if (GET_PARAM(2) != VPX_VBR) return; + key_interval_ = 100; + SetConfig(VPX_VBR); + rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); + frame_params_.spatial_layer_id = 0; + frame_params_.temporal_layer_id = 0; + + ::libvpx_test::I420VideoSource video("desktop_office1.1280_720-020.yuv", + 1280, 720, 30, 1, 0, kNumFrames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + private: + void SetConfig(vpx_rc_mode rc_mode) { + rc_cfg_.width = 1280; + rc_cfg_.height = 720; + rc_cfg_.max_quantizer = 52; + rc_cfg_.min_quantizer = 2; + rc_cfg_.target_bandwidth = 1000; + rc_cfg_.buf_initial_sz = 600; + rc_cfg_.buf_optimal_sz = 600; + rc_cfg_.buf_sz = 1000; + rc_cfg_.undershoot_pct = 50; + rc_cfg_.overshoot_pct = 50; + rc_cfg_.max_intra_bitrate_pct = 1000; + rc_cfg_.framerate = 30.0; + rc_cfg_.ss_number_layers = 1; + rc_cfg_.ts_number_layers = 1; + rc_cfg_.scaling_factor_num[0] = 1; + rc_cfg_.scaling_factor_den[0] = 1; + rc_cfg_.layer_target_bitrate[0] = 1000; + rc_cfg_.max_quantizers[0] = 52; + rc_cfg_.min_quantizers[0] = 2; + rc_cfg_.rc_mode = rc_mode; + rc_cfg_.aq_mode = aq_mode_; + + // Encoder settings for ground truth. + cfg_.g_w = 1280; + cfg_.g_h = 720; + cfg_.rc_undershoot_pct = 50; + cfg_.rc_overshoot_pct = 50; + cfg_.rc_buf_initial_sz = 600; + cfg_.rc_buf_optimal_sz = 600; + cfg_.rc_buf_sz = 1000; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_min_quantizer = 2; + cfg_.rc_max_quantizer = 52; + cfg_.rc_end_usage = rc_mode; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 0; + cfg_.rc_target_bitrate = 1000; + cfg_.kf_min_dist = key_interval_; + cfg_.kf_max_dist = key_interval_; + } + + std::unique_ptr rc_api_; + libvpx::VP9RateControlRtcConfig rc_cfg_; + int aq_mode_; + int key_interval_; + libvpx::VP9FrameParamsQpRTC frame_params_; + bool encoder_exit_; +}; + +class RcInterfaceSvcTest : public ::libvpx_test::EncoderTest, + public ::libvpx_test::CodecTestWithParam { + public: + RcInterfaceSvcTest() : EncoderTest(GET_PARAM(0)), aq_mode_(GET_PARAM(1)) {} + virtual ~RcInterfaceSvcTest() {} + + protected: + virtual void SetUp() { + InitializeConfig(); + SetMode(::libvpx_test::kRealTime); + } + + virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video, + ::libvpx_test::Encoder *encoder) { + if (video->frame() == 0) { + encoder->Control(VP8E_SET_CPUUSED, 7); + encoder->Control(VP9E_SET_AQ_MODE, aq_mode_); + encoder->Control(VP9E_SET_TUNE_CONTENT, 0); + encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 900); + encoder->Control(VP9E_SET_RTC_EXTERNAL_RATECTRL, 1); + encoder->Control(VP9E_SET_SVC, 1); + encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_); + } + + frame_params_.frame_type = video->frame() == 0 ? KEY_FRAME : INTER_FRAME; + if (rc_cfg_.rc_mode == VPX_CBR && frame_params_.frame_type == INTER_FRAME) { + // Disable golden frame update. + frame_flags_ |= VP8_EFLAG_NO_UPD_GF; + frame_flags_ |= VP8_EFLAG_NO_UPD_ARF; + } + encoder_exit_ = video->frame() == kNumFrames; + current_superframe_ = video->frame(); + } + + virtual void PostEncodeFrameHook(::libvpx_test::Encoder *encoder) { + ::libvpx_test::CxDataIterator iter = encoder->GetCxData(); + while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) { + ParseSuperframeSizes(static_cast(pkt->data.frame.buf), + pkt->data.frame.sz); + for (int sl = 0; sl < rc_cfg_.ss_number_layers; sl++) { + frame_params_.spatial_layer_id = sl; + frame_params_.temporal_layer_id = kTemporalId[current_superframe_ % 4]; + rc_api_->ComputeQP(frame_params_); + frame_params_.frame_type = INTER_FRAME; + rc_api_->PostEncodeUpdate(sizes_[sl]); + } + } + if (!encoder_exit_) { + int loopfilter_level, qp; + encoder->Control(VP9E_GET_LOOPFILTER_LEVEL, &loopfilter_level); + encoder->Control(VP8E_GET_LAST_QUANTIZER, &qp); + ASSERT_EQ(rc_api_->GetQP(), qp); + ASSERT_EQ(rc_api_->GetLoopfilterLevel(), loopfilter_level); + } + } + // This method needs to be overridden because non-reference frames are + // expected to be mismatched frames as the encoder will avoid loopfilter on + // these frames. + virtual void MismatchHook(const vpx_image_t * /*img1*/, + const vpx_image_t * /*img2*/) {} + + void RunSvc() { + SetConfigSvc(); + rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); + SetEncoderSvc(); + + ::libvpx_test::I420VideoSource video("desktop_office1.1280_720-020.yuv", + 1280, 720, 30, 1, 0, kNumFrames); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + + private: + vpx_codec_err_t ParseSuperframeSizes(const uint8_t *data, size_t data_sz) { + uint8_t marker = *(data + data_sz - 1); + if ((marker & 0xe0) == 0xc0) { + const uint32_t frames = (marker & 0x7) + 1; + const uint32_t mag = ((marker >> 3) & 0x3) + 1; + const size_t index_sz = 2 + mag * frames; + // This chunk is marked as having a superframe index but doesn't have + // enough data for it, thus it's an invalid superframe index. + if (data_sz < index_sz) return VPX_CODEC_CORRUPT_FRAME; + { + const uint8_t marker2 = *(data + data_sz - index_sz); + // This chunk is marked as having a superframe index but doesn't have + // the matching marker byte at the front of the index therefore it's an + // invalid chunk. + if (marker != marker2) return VPX_CODEC_CORRUPT_FRAME; + } + const uint8_t *x = &data[data_sz - index_sz + 1]; + for (uint32_t i = 0; i < frames; ++i) { + uint32_t this_sz = 0; + + for (uint32_t j = 0; j < mag; ++j) this_sz |= (*x++) << (j * 8); + sizes_[i] = this_sz; + } + } + return VPX_CODEC_OK; + } + + void SetEncoderSvc() { + cfg_.ss_number_layers = 3; + cfg_.ts_number_layers = 3; + cfg_.g_timebase.num = 1; + cfg_.g_timebase.den = 30; + svc_params_.scaling_factor_num[0] = 72; + svc_params_.scaling_factor_den[0] = 288; + svc_params_.scaling_factor_num[1] = 144; + svc_params_.scaling_factor_den[1] = 288; + svc_params_.scaling_factor_num[2] = 288; + svc_params_.scaling_factor_den[2] = 288; + for (int i = 0; i < VPX_MAX_LAYERS; ++i) { + svc_params_.max_quantizers[i] = 56; + svc_params_.min_quantizers[i] = 2; + svc_params_.speed_per_layer[i] = 7; + } + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_lag_in_frames = 0; + cfg_.g_error_resilient = 0; + // 3 temporal layers + cfg_.ts_rate_decimator[0] = 4; + cfg_.ts_rate_decimator[1] = 2; + cfg_.ts_rate_decimator[2] = 1; + cfg_.temporal_layering_mode = 3; + + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 600; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 2; + cfg_.rc_max_quantizer = 56; + cfg_.g_threads = 1; + cfg_.kf_max_dist = 9999; + cfg_.rc_target_bitrate = 1600; + cfg_.rc_overshoot_pct = 50; + cfg_.rc_undershoot_pct = 50; + + cfg_.layer_target_bitrate[0] = 100; + cfg_.layer_target_bitrate[1] = 140; + cfg_.layer_target_bitrate[2] = 200; + cfg_.layer_target_bitrate[3] = 250; + cfg_.layer_target_bitrate[4] = 350; + cfg_.layer_target_bitrate[5] = 500; + cfg_.layer_target_bitrate[6] = 450; + cfg_.layer_target_bitrate[7] = 630; + cfg_.layer_target_bitrate[8] = 900; + } + + void SetConfigSvc() { + rc_cfg_.width = 1280; + rc_cfg_.height = 720; + rc_cfg_.max_quantizer = 56; + rc_cfg_.min_quantizer = 2; + rc_cfg_.target_bandwidth = 1600; + rc_cfg_.buf_initial_sz = 500; + rc_cfg_.buf_optimal_sz = 600; + rc_cfg_.buf_sz = 1000; + rc_cfg_.undershoot_pct = 50; + rc_cfg_.overshoot_pct = 50; + rc_cfg_.max_intra_bitrate_pct = 900; + rc_cfg_.framerate = 30.0; + rc_cfg_.ss_number_layers = 3; + rc_cfg_.ts_number_layers = 3; + rc_cfg_.rc_mode = VPX_CBR; + rc_cfg_.aq_mode = aq_mode_; + + rc_cfg_.scaling_factor_num[0] = 1; + rc_cfg_.scaling_factor_den[0] = 4; + rc_cfg_.scaling_factor_num[1] = 2; + rc_cfg_.scaling_factor_den[1] = 4; + rc_cfg_.scaling_factor_num[2] = 4; + rc_cfg_.scaling_factor_den[2] = 4; + + rc_cfg_.ts_rate_decimator[0] = 4; + rc_cfg_.ts_rate_decimator[1] = 2; + rc_cfg_.ts_rate_decimator[2] = 1; + + rc_cfg_.layer_target_bitrate[0] = 100; + rc_cfg_.layer_target_bitrate[1] = 140; + rc_cfg_.layer_target_bitrate[2] = 200; + rc_cfg_.layer_target_bitrate[3] = 250; + rc_cfg_.layer_target_bitrate[4] = 350; + rc_cfg_.layer_target_bitrate[5] = 500; + rc_cfg_.layer_target_bitrate[6] = 450; + rc_cfg_.layer_target_bitrate[7] = 630; + rc_cfg_.layer_target_bitrate[8] = 900; + + for (int sl = 0; sl < rc_cfg_.ss_number_layers; ++sl) { + for (int tl = 0; tl < rc_cfg_.ts_number_layers; ++tl) { + const int i = sl * rc_cfg_.ts_number_layers + tl; + rc_cfg_.max_quantizers[i] = 56; + rc_cfg_.min_quantizers[i] = 2; + } + } + } + + int aq_mode_; + std::unique_ptr rc_api_; + libvpx::VP9RateControlRtcConfig rc_cfg_; + vpx_svc_extra_cfg_t svc_params_; + libvpx::VP9FrameParamsQpRTC frame_params_; + bool encoder_exit_; + int current_superframe_; + uint32_t sizes_[8]; +}; + +TEST_P(RcInterfaceTest, OneLayer) { RunOneLayer(); } + +TEST_P(RcInterfaceTest, OneLayerVBRPeriodicKey) { RunOneLayerVBRPeriodicKey(); } + +TEST_P(RcInterfaceSvcTest, Svc) { RunSvc(); } + +VP9_INSTANTIATE_TEST_SUITE(RcInterfaceTest, ::testing::Values(0, 3), + ::testing::Values(VPX_CBR, VPX_VBR)); +VP9_INSTANTIATE_TEST_SUITE(RcInterfaceSvcTest, ::testing::Values(0, 3)); +} // namespace diff --git a/third_party/libvpx/test/vp9_scale_test.cc b/third_party/libvpx/source/libvpx/test/vp9_scale_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_scale_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_scale_test.cc diff --git a/third_party/libvpx/test/vp9_skip_loopfilter_test.cc b/third_party/libvpx/source/libvpx/test/vp9_skip_loopfilter_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_skip_loopfilter_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_skip_loopfilter_test.cc diff --git a/third_party/libvpx/test/vp9_subtract_test.cc b/third_party/libvpx/source/libvpx/test/vp9_subtract_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_subtract_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_subtract_test.cc diff --git a/third_party/libvpx/test/vp9_thread_test.cc b/third_party/libvpx/source/libvpx/test/vp9_thread_test.cc similarity index 100% rename from third_party/libvpx/test/vp9_thread_test.cc rename to third_party/libvpx/source/libvpx/test/vp9_thread_test.cc diff --git a/third_party/libvpx/test/vpx_scale_test.cc b/third_party/libvpx/source/libvpx/test/vpx_scale_test.cc similarity index 100% rename from third_party/libvpx/test/vpx_scale_test.cc rename to third_party/libvpx/source/libvpx/test/vpx_scale_test.cc diff --git a/third_party/libvpx/test/vpx_scale_test.h b/third_party/libvpx/source/libvpx/test/vpx_scale_test.h similarity index 100% rename from third_party/libvpx/test/vpx_scale_test.h rename to third_party/libvpx/source/libvpx/test/vpx_scale_test.h diff --git a/third_party/libvpx/test/vpx_temporal_svc_encoder.sh b/third_party/libvpx/source/libvpx/test/vpx_temporal_svc_encoder.sh similarity index 100% rename from third_party/libvpx/test/vpx_temporal_svc_encoder.sh rename to third_party/libvpx/source/libvpx/test/vpx_temporal_svc_encoder.sh diff --git a/third_party/libvpx/test/vpxdec.sh b/third_party/libvpx/source/libvpx/test/vpxdec.sh similarity index 100% rename from third_party/libvpx/test/vpxdec.sh rename to third_party/libvpx/source/libvpx/test/vpxdec.sh diff --git a/third_party/libvpx/test/vpxenc.sh b/third_party/libvpx/source/libvpx/test/vpxenc.sh similarity index 100% rename from third_party/libvpx/test/vpxenc.sh rename to third_party/libvpx/source/libvpx/test/vpxenc.sh diff --git a/third_party/libvpx/test/webm_video_source.h b/third_party/libvpx/source/libvpx/test/webm_video_source.h similarity index 100% rename from third_party/libvpx/test/webm_video_source.h rename to third_party/libvpx/source/libvpx/test/webm_video_source.h diff --git a/third_party/libvpx/test/y4m_test.cc b/third_party/libvpx/source/libvpx/test/y4m_test.cc similarity index 79% rename from third_party/libvpx/test/y4m_test.cc rename to third_party/libvpx/source/libvpx/test/y4m_test.cc index 46cb5cff807e..8272263f66a8 100644 --- a/third_party/libvpx/test/y4m_test.cc +++ b/third_party/libvpx/source/libvpx/test/y4m_test.cc @@ -188,4 +188,55 @@ TEST_P(Y4mVideoWriteTest, WriteTest) { INSTANTIATE_TEST_SUITE_P(C, Y4mVideoWriteTest, ::testing::ValuesIn(kY4mTestVectors)); + +static const char kY4MRegularHeader[] = + "YUV4MPEG2 W4 H4 F30:1 Ip A0:0 C420jpeg XYSCSS=420JPEG\n" + "FRAME\n" + "012345678912345601230123"; + +TEST(Y4MHeaderTest, RegularHeader) { + libvpx_test::TempOutFile f; + fwrite(kY4MRegularHeader, 1, sizeof(kY4MRegularHeader), f.file()); + fflush(f.file()); + EXPECT_EQ(0, fseek(f.file(), 0, 0)); + + y4m_input y4m; + EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/NULL, + /*num_skip=*/0, /*only_420=*/0), + 0); + EXPECT_EQ(y4m.pic_w, 4); + EXPECT_EQ(y4m.pic_h, 4); + EXPECT_EQ(y4m.fps_n, 30); + EXPECT_EQ(y4m.fps_d, 1); + EXPECT_EQ(y4m.interlace, 'p'); + EXPECT_EQ(strcmp("420jpeg", y4m.chroma_type), 0); + y4m_input_close(&y4m); +} + +// Testing that headers over 100 characters can be parsed. +static const char kY4MLongHeader[] = + "YUV4MPEG2 W4 H4 F30:1 Ip A0:0 C420jpeg XYSCSS=420JPEG " + "XCOLORRANGE=LIMITED XSOME_UNKNOWN_METADATA XOTHER_UNKNOWN_METADATA\n" + "FRAME\n" + "012345678912345601230123"; + +TEST(Y4MHeaderTest, LongHeader) { + libvpx_test::TempOutFile f; + fwrite(kY4MLongHeader, 1, sizeof(kY4MLongHeader), f.file()); + fflush(f.file()); + EXPECT_EQ(fseek(f.file(), 0, 0), 0); + + y4m_input y4m; + EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/NULL, + /*num_skip=*/0, /*only_420=*/0), + 0); + EXPECT_EQ(y4m.pic_w, 4); + EXPECT_EQ(y4m.pic_h, 4); + EXPECT_EQ(y4m.fps_n, 30); + EXPECT_EQ(y4m.fps_d, 1); + EXPECT_EQ(y4m.interlace, 'p'); + EXPECT_EQ(strcmp("420jpeg", y4m.chroma_type), 0); + y4m_input_close(&y4m); +} + } // namespace diff --git a/third_party/libvpx/test/y4m_video_source.h b/third_party/libvpx/source/libvpx/test/y4m_video_source.h similarity index 100% rename from third_party/libvpx/test/y4m_video_source.h rename to third_party/libvpx/source/libvpx/test/y4m_video_source.h diff --git a/third_party/libvpx/test/yuv_temporal_filter_test.cc b/third_party/libvpx/source/libvpx/test/yuv_temporal_filter_test.cc similarity index 100% rename from third_party/libvpx/test/yuv_temporal_filter_test.cc rename to third_party/libvpx/source/libvpx/test/yuv_temporal_filter_test.cc diff --git a/third_party/libvpx/test/yuv_video_source.h b/third_party/libvpx/source/libvpx/test/yuv_video_source.h similarity index 100% rename from third_party/libvpx/test/yuv_video_source.h rename to third_party/libvpx/source/libvpx/test/yuv_video_source.h diff --git a/third_party/libvpx/third_party/googletest/README.libvpx b/third_party/libvpx/source/libvpx/third_party/googletest/README.libvpx similarity index 84% rename from third_party/libvpx/third_party/googletest/README.libvpx rename to third_party/libvpx/source/libvpx/third_party/googletest/README.libvpx index 0f6202cb7b8f..ed55fb09f93b 100644 --- a/third_party/libvpx/third_party/googletest/README.libvpx +++ b/third_party/libvpx/source/libvpx/third_party/googletest/README.libvpx @@ -19,3 +19,5 @@ Local Modifications: LICENSE README.md src +- Enable kErrorOnUninstantiatedParameterizedTest and + kErrorOnUninstantiatedTypeParameterizedTest in gtest.cc diff --git a/third_party/libvpx/third_party/googletest/gtest.mk b/third_party/libvpx/source/libvpx/third_party/googletest/gtest.mk similarity index 100% rename from third_party/libvpx/third_party/googletest/gtest.mk rename to third_party/libvpx/source/libvpx/third_party/googletest/gtest.mk diff --git a/third_party/libvpx/third_party/googletest/src/CONTRIBUTORS b/third_party/libvpx/source/libvpx/third_party/googletest/src/CONTRIBUTORS similarity index 100% rename from third_party/libvpx/third_party/googletest/src/CONTRIBUTORS rename to third_party/libvpx/source/libvpx/third_party/googletest/src/CONTRIBUTORS diff --git a/third_party/libvpx/third_party/googletest/src/LICENSE b/third_party/libvpx/source/libvpx/third_party/googletest/src/LICENSE similarity index 100% rename from third_party/libvpx/third_party/googletest/src/LICENSE rename to third_party/libvpx/source/libvpx/third_party/googletest/src/LICENSE diff --git a/third_party/libvpx/third_party/googletest/src/README.md b/third_party/libvpx/source/libvpx/third_party/googletest/src/README.md similarity index 100% rename from third_party/libvpx/third_party/googletest/src/README.md rename to third_party/libvpx/source/libvpx/third_party/googletest/src/README.md diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-death-test.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-death-test.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-death-test.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-death-test.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-matchers.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-matchers.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-matchers.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-matchers.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-message.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-message.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-message.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-message.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-param-test.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-param-test.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-param-test.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-param-test.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-printers.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-printers.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-printers.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-printers.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-spi.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-spi.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-spi.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-spi.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-test-part.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-test-part.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-test-part.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-test-part.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest-typed-test.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-typed-test.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest-typed-test.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest-typed-test.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest_pred_impl.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest_pred_impl.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest_pred_impl.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest_pred_impl.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/gtest_prod.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest_prod.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/gtest_prod.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/gtest_prod.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/README.md b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/README.md similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/README.md rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/README.md diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-port.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-port.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-port.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-port.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/custom/gtest.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-filepath.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-filepath.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-filepath.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-filepath.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-internal.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-internal.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-internal.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-internal.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-param-util.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-param-util.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-param-util.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-param-util.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port-arch.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port-arch.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port-arch.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port-arch.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-port.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-string.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-string.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-string.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-string.h diff --git a/third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-type-util.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-type-util.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/include/gtest/internal/gtest-type-util.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/include/gtest/internal/gtest-type-util.h diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-all.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-all.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-all.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-all.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-death-test.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-death-test.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-death-test.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-death-test.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-filepath.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-filepath.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-filepath.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-filepath.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-internal-inl.h b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-internal-inl.h similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-internal-inl.h rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-internal-inl.h diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-matchers.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-matchers.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-matchers.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-matchers.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-port.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-port.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-port.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-port.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-printers.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-printers.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-printers.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-printers.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-test-part.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-test-part.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-test-part.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-test-part.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest-typed-test.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-typed-test.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest-typed-test.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest-typed-test.cc diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest.cc similarity index 99% rename from third_party/libvpx/third_party/googletest/src/src/gtest.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest.cc index 095778e6e93f..b8f6a5c31cc8 100644 --- a/third_party/libvpx/third_party/googletest/src/src/gtest.cc +++ b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest.cc @@ -414,8 +414,8 @@ namespace { // inserted to report ether an error or a log message. // // This configuration bit will likely be removed at some point. -constexpr bool kErrorOnUninstantiatedParameterizedTest = false; -constexpr bool kErrorOnUninstantiatedTypeParameterizedTest = false; +constexpr bool kErrorOnUninstantiatedParameterizedTest = true; +constexpr bool kErrorOnUninstantiatedTypeParameterizedTest = true; // A test that fails at a given file/line location with a given message. class FailureTest : public Test { diff --git a/third_party/libvpx/third_party/googletest/src/src/gtest_main.cc b/third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest_main.cc similarity index 100% rename from third_party/libvpx/third_party/googletest/src/src/gtest_main.cc rename to third_party/libvpx/source/libvpx/third_party/googletest/src/src/gtest_main.cc diff --git a/third_party/libvpx/third_party/libwebm/AUTHORS.TXT b/third_party/libvpx/source/libvpx/third_party/libwebm/AUTHORS.TXT similarity index 100% rename from third_party/libvpx/third_party/libwebm/AUTHORS.TXT rename to third_party/libvpx/source/libvpx/third_party/libwebm/AUTHORS.TXT diff --git a/third_party/libvpx/third_party/libwebm/Android.mk b/third_party/libvpx/source/libvpx/third_party/libwebm/Android.mk similarity index 91% rename from third_party/libvpx/third_party/libwebm/Android.mk rename to third_party/libvpx/source/libvpx/third_party/libwebm/Android.mk index b46ba101d420..3b3dd1d3903e 100644 --- a/third_party/libvpx/third_party/libwebm/Android.mk +++ b/third_party/libvpx/source/libvpx/third_party/libwebm/Android.mk @@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= libwebm LOCAL_CPPFLAGS:=-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -LOCAL_CPPFLAGS+=-D__STDC_LIMIT_MACROS -std=c++11 +LOCAL_CPPFLAGS+=-D__STDC_LIMIT_MACROS -std=gnu++11 LOCAL_C_INCLUDES:= $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH) diff --git a/third_party/libvpx/third_party/libwebm/LICENSE.TXT b/third_party/libvpx/source/libvpx/third_party/libwebm/LICENSE.TXT similarity index 100% rename from third_party/libvpx/third_party/libwebm/LICENSE.TXT rename to third_party/libvpx/source/libvpx/third_party/libwebm/LICENSE.TXT diff --git a/third_party/libvpx/third_party/libwebm/PATENTS.TXT b/third_party/libvpx/source/libvpx/third_party/libwebm/PATENTS.TXT similarity index 100% rename from third_party/libvpx/third_party/libwebm/PATENTS.TXT rename to third_party/libvpx/source/libvpx/third_party/libwebm/PATENTS.TXT diff --git a/third_party/libvpx/third_party/libwebm/README.libvpx b/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx similarity index 100% rename from third_party/libvpx/third_party/libwebm/README.libvpx rename to third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx diff --git a/third_party/libvpx/third_party/libwebm/common/file_util.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/common/file_util.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/common/file_util.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/common/file_util.cc diff --git a/third_party/libvpx/third_party/libwebm/common/file_util.h b/third_party/libvpx/source/libvpx/third_party/libwebm/common/file_util.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/common/file_util.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/common/file_util.h diff --git a/third_party/libvpx/third_party/libwebm/common/hdr_util.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/common/hdr_util.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/common/hdr_util.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/common/hdr_util.cc diff --git a/third_party/libvpx/third_party/libwebm/common/hdr_util.h b/third_party/libvpx/source/libvpx/third_party/libwebm/common/hdr_util.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/common/hdr_util.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/common/hdr_util.h diff --git a/third_party/libvpx/third_party/libwebm/common/webmids.h b/third_party/libvpx/source/libvpx/third_party/libwebm/common/webmids.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/common/webmids.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/common/webmids.h diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.cc diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxer.h diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxertypes.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxertypes.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxertypes.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxertypes.h diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvmuxerutil.h diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.cc diff --git a/third_party/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvmuxer/mkvwriter.h diff --git a/third_party/libvpx/third_party/libwebm/mkvparser/mkvparser.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvparser/mkvparser.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc diff --git a/third_party/libvpx/third_party/libwebm/mkvparser/mkvparser.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvparser/mkvparser.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.h diff --git a/third_party/libvpx/third_party/libwebm/mkvparser/mkvreader.cc b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvparser/mkvreader.cc rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc diff --git a/third_party/libvpx/third_party/libwebm/mkvparser/mkvreader.h b/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvreader.h similarity index 100% rename from third_party/libvpx/third_party/libwebm/mkvparser/mkvreader.h rename to third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvreader.h diff --git a/third_party/libvpx/third_party/libyuv/LICENSE b/third_party/libvpx/source/libvpx/third_party/libyuv/LICENSE similarity index 100% rename from third_party/libvpx/third_party/libyuv/LICENSE rename to third_party/libvpx/source/libvpx/third_party/libyuv/LICENSE diff --git a/third_party/libvpx/third_party/libyuv/README.libvpx b/third_party/libvpx/source/libvpx/third_party/libyuv/README.libvpx similarity index 100% rename from third_party/libvpx/third_party/libyuv/README.libvpx rename to third_party/libvpx/source/libvpx/third_party/libyuv/README.libvpx diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/basic_types.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/basic_types.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/basic_types.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/basic_types.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/compare.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/compare.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/compare.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/compare.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/convert.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/convert.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/convert_argb.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_argb.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/convert_argb.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_argb.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/convert_from.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_from.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/convert_from.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_from.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/convert_from_argb.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_from_argb.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/convert_from_argb.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/convert_from_argb.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/cpu_id.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/cpu_id.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/cpu_id.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/cpu_id.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/macros_msa.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/macros_msa.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/macros_msa.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/macros_msa.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/mjpeg_decoder.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/mjpeg_decoder.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/mjpeg_decoder.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/mjpeg_decoder.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/planar_functions.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/planar_functions.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/planar_functions.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/planar_functions.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/rotate.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/rotate.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/rotate_argb.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate_argb.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/rotate_argb.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate_argb.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/rotate_row.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate_row.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/rotate_row.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/rotate_row.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/row.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/row.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/row.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/row.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/scale.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/scale.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/scale_argb.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale_argb.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/scale_argb.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale_argb.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/scale_row.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale_row.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/scale_row.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/scale_row.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/version.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/version.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/version.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/version.h diff --git a/third_party/libvpx/third_party/libyuv/include/libyuv/video_common.h b/third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/video_common.h similarity index 100% rename from third_party/libvpx/third_party/libyuv/include/libyuv/video_common.h rename to third_party/libvpx/source/libvpx/third_party/libyuv/include/libyuv/video_common.h diff --git a/third_party/libvpx/third_party/libyuv/source/compare.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_common.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_common.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_common.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_common.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_gcc.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_gcc.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_gcc.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_gcc.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_msa.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_msa.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_msa.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_msa.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_neon.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_neon.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_neon.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_neon.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_neon64.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_neon64.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_neon64.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_neon64.cc diff --git a/third_party/libvpx/third_party/libyuv/source/compare_win.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_win.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/compare_win.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/compare_win.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_argb.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_argb.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_argb.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_argb.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_from.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_from.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_from.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_from.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_from_argb.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_from_argb.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_from_argb.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_from_argb.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_jpeg.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_jpeg.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_jpeg.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_jpeg.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_to_argb.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_to_argb.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_to_argb.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_to_argb.cc diff --git a/third_party/libvpx/third_party/libyuv/source/convert_to_i420.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_to_i420.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/convert_to_i420.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/convert_to_i420.cc diff --git a/third_party/libvpx/third_party/libyuv/source/cpu_id.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/cpu_id.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/cpu_id.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/cpu_id.cc diff --git a/third_party/libvpx/third_party/libyuv/source/mjpeg_decoder.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/mjpeg_decoder.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/mjpeg_decoder.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/mjpeg_decoder.cc diff --git a/third_party/libvpx/third_party/libyuv/source/mjpeg_validate.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/mjpeg_validate.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/mjpeg_validate.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/mjpeg_validate.cc diff --git a/third_party/libvpx/third_party/libyuv/source/planar_functions.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/planar_functions.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/planar_functions.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/planar_functions.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_any.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_any.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_any.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_any.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_argb.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_argb.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_argb.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_argb.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_common.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_common.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_common.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_common.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_gcc.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_gcc.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_gcc.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_gcc.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_msa.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_msa.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_msa.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_msa.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_neon.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_neon.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_neon.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_neon.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_neon64.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_neon64.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_neon64.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_neon64.cc diff --git a/third_party/libvpx/third_party/libyuv/source/rotate_win.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_win.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/rotate_win.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/rotate_win.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_any.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_any.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_any.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_any.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_common.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_common.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_common.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_common.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_gcc.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_gcc.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_gcc.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_gcc.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_msa.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_msa.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_msa.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_msa.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_neon.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_neon.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_neon.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_neon.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_neon64.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_neon64.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_neon64.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_neon64.cc diff --git a/third_party/libvpx/third_party/libyuv/source/row_win.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/row_win.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/row_win.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/row_win.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_any.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_any.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_any.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_any.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_argb.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_argb.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_argb.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_argb.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_common.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_common.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_common.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_common.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_gcc.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_gcc.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_gcc.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_gcc.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_msa.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_msa.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_msa.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_msa.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_neon.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_neon.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_neon.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_neon.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_neon64.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_neon64.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_neon64.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_neon64.cc diff --git a/third_party/libvpx/third_party/libyuv/source/scale_win.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_win.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/scale_win.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/scale_win.cc diff --git a/third_party/libvpx/third_party/libyuv/source/video_common.cc b/third_party/libvpx/source/libvpx/third_party/libyuv/source/video_common.cc similarity index 100% rename from third_party/libvpx/third_party/libyuv/source/video_common.cc rename to third_party/libvpx/source/libvpx/third_party/libyuv/source/video_common.cc diff --git a/third_party/libvpx/third_party/x86inc/LICENSE b/third_party/libvpx/source/libvpx/third_party/x86inc/LICENSE similarity index 100% rename from third_party/libvpx/third_party/x86inc/LICENSE rename to third_party/libvpx/source/libvpx/third_party/x86inc/LICENSE diff --git a/third_party/libvpx/third_party/x86inc/README.libvpx b/third_party/libvpx/source/libvpx/third_party/x86inc/README.libvpx similarity index 100% rename from third_party/libvpx/third_party/x86inc/README.libvpx rename to third_party/libvpx/source/libvpx/third_party/x86inc/README.libvpx diff --git a/third_party/libvpx/third_party/x86inc/x86inc.asm b/third_party/libvpx/source/libvpx/third_party/x86inc/x86inc.asm similarity index 100% rename from third_party/libvpx/third_party/x86inc/x86inc.asm rename to third_party/libvpx/source/libvpx/third_party/x86inc/x86inc.asm diff --git a/third_party/libvpx/tools.mk b/third_party/libvpx/source/libvpx/tools.mk similarity index 99% rename from third_party/libvpx/tools.mk rename to third_party/libvpx/source/libvpx/tools.mk index 1d005b2acfb1..dd2ebeb3d51e 100644 --- a/third_party/libvpx/tools.mk +++ b/third_party/libvpx/source/libvpx/tools.mk @@ -79,6 +79,7 @@ $(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX) --ver=$$(CONFIG_VS_VERSION)\ --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\ --src-path-bare="$(SRC_PATH_BARE)" \ + --as=$$(AS) \ $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \ --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \ $$(INTERNAL_LDFLAGS) $$(LDFLAGS) $$^ diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/Anandan.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Anandan.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/Anandan.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Anandan.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/SearchSmooth.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/SearchSmooth.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/SearchSmooth.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/SearchSmooth.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/MotionEST/Util.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/MotionEST/Util.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde diff --git a/third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde b/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde similarity index 100% rename from third_party/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde rename to third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde diff --git a/third_party/libvpx/tools/cpplint.py b/third_party/libvpx/source/libvpx/tools/cpplint.py similarity index 100% rename from third_party/libvpx/tools/cpplint.py rename to third_party/libvpx/source/libvpx/tools/cpplint.py diff --git a/third_party/libvpx/tools/diff.py b/third_party/libvpx/source/libvpx/tools/diff.py similarity index 100% rename from third_party/libvpx/tools/diff.py rename to third_party/libvpx/source/libvpx/tools/diff.py diff --git a/third_party/libvpx/tools/gen_authors.sh b/third_party/libvpx/source/libvpx/tools/gen_authors.sh similarity index 100% rename from third_party/libvpx/tools/gen_authors.sh rename to third_party/libvpx/source/libvpx/tools/gen_authors.sh diff --git a/third_party/libvpx/tools/intersect-diffs.py b/third_party/libvpx/source/libvpx/tools/intersect-diffs.py similarity index 100% rename from third_party/libvpx/tools/intersect-diffs.py rename to third_party/libvpx/source/libvpx/tools/intersect-diffs.py diff --git a/third_party/libvpx/tools/lint-hunks.py b/third_party/libvpx/source/libvpx/tools/lint-hunks.py similarity index 100% rename from third_party/libvpx/tools/lint-hunks.py rename to third_party/libvpx/source/libvpx/tools/lint-hunks.py diff --git a/third_party/libvpx/tools/non_greedy_mv/non_greedy_mv.py b/third_party/libvpx/source/libvpx/tools/non_greedy_mv/non_greedy_mv.py similarity index 100% rename from third_party/libvpx/tools/non_greedy_mv/non_greedy_mv.py rename to third_party/libvpx/source/libvpx/tools/non_greedy_mv/non_greedy_mv.py diff --git a/third_party/libvpx/tools/set_analyzer_env.sh b/third_party/libvpx/source/libvpx/tools/set_analyzer_env.sh similarity index 100% rename from third_party/libvpx/tools/set_analyzer_env.sh rename to third_party/libvpx/source/libvpx/tools/set_analyzer_env.sh diff --git a/third_party/libvpx/tools/tiny_ssim.c b/third_party/libvpx/source/libvpx/tools/tiny_ssim.c similarity index 100% rename from third_party/libvpx/tools/tiny_ssim.c rename to third_party/libvpx/source/libvpx/tools/tiny_ssim.c diff --git a/third_party/libvpx/tools/wrap-commit-msg.py b/third_party/libvpx/source/libvpx/tools/wrap-commit-msg.py similarity index 100% rename from third_party/libvpx/tools/wrap-commit-msg.py rename to third_party/libvpx/source/libvpx/tools/wrap-commit-msg.py diff --git a/third_party/libvpx/tools_common.c b/third_party/libvpx/source/libvpx/tools_common.c similarity index 100% rename from third_party/libvpx/tools_common.c rename to third_party/libvpx/source/libvpx/tools_common.c diff --git a/third_party/libvpx/tools_common.h b/third_party/libvpx/source/libvpx/tools_common.h similarity index 94% rename from third_party/libvpx/tools_common.h rename to third_party/libvpx/source/libvpx/tools_common.h index 4526d9f165c0..4e8851fc15cf 100644 --- a/third_party/libvpx/tools_common.h +++ b/third_party/libvpx/source/libvpx/tools_common.h @@ -110,6 +110,8 @@ extern "C" { #if defined(__GNUC__) #define VPX_NO_RETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define VPX_NO_RETURN __declspec(noreturn) #else #define VPX_NO_RETURN #endif @@ -117,14 +119,14 @@ extern "C" { /* Sets a stdio stream into binary mode */ FILE *set_binary_mode(FILE *stream); -void die(const char *fmt, ...) VPX_NO_RETURN; -void fatal(const char *fmt, ...) VPX_NO_RETURN; +VPX_NO_RETURN void die(const char *fmt, ...); +VPX_NO_RETURN void fatal(const char *fmt, ...); void warn(const char *fmt, ...); -void die_codec(vpx_codec_ctx_t *ctx, const char *s) VPX_NO_RETURN; +VPX_NO_RETURN void die_codec(vpx_codec_ctx_t *ctx, const char *s); /* The tool including this file must define usage_exit() */ -void usage_exit(void) VPX_NO_RETURN; +VPX_NO_RETURN void usage_exit(void); #undef VPX_NO_RETURN diff --git a/third_party/libvpx/usage.dox b/third_party/libvpx/source/libvpx/usage.dox similarity index 100% rename from third_party/libvpx/usage.dox rename to third_party/libvpx/source/libvpx/usage.dox diff --git a/third_party/libvpx/usage_cx.dox b/third_party/libvpx/source/libvpx/usage_cx.dox similarity index 100% rename from third_party/libvpx/usage_cx.dox rename to third_party/libvpx/source/libvpx/usage_cx.dox diff --git a/third_party/libvpx/usage_dx.dox b/third_party/libvpx/source/libvpx/usage_dx.dox similarity index 100% rename from third_party/libvpx/usage_dx.dox rename to third_party/libvpx/source/libvpx/usage_dx.dox diff --git a/third_party/libvpx/video_common.h b/third_party/libvpx/source/libvpx/video_common.h similarity index 100% rename from third_party/libvpx/video_common.h rename to third_party/libvpx/source/libvpx/video_common.h diff --git a/third_party/libvpx/video_reader.c b/third_party/libvpx/source/libvpx/video_reader.c similarity index 100% rename from third_party/libvpx/video_reader.c rename to third_party/libvpx/source/libvpx/video_reader.c diff --git a/third_party/libvpx/video_reader.h b/third_party/libvpx/source/libvpx/video_reader.h similarity index 100% rename from third_party/libvpx/video_reader.h rename to third_party/libvpx/source/libvpx/video_reader.h diff --git a/third_party/libvpx/video_writer.c b/third_party/libvpx/source/libvpx/video_writer.c similarity index 100% rename from third_party/libvpx/video_writer.c rename to third_party/libvpx/source/libvpx/video_writer.c diff --git a/third_party/libvpx/video_writer.h b/third_party/libvpx/source/libvpx/video_writer.h similarity index 100% rename from third_party/libvpx/video_writer.h rename to third_party/libvpx/source/libvpx/video_writer.h diff --git a/third_party/libvpx/vp8/common/alloccommon.c b/third_party/libvpx/source/libvpx/vp8/common/alloccommon.c similarity index 100% rename from third_party/libvpx/vp8/common/alloccommon.c rename to third_party/libvpx/source/libvpx/vp8/common/alloccommon.c diff --git a/third_party/libvpx/vp8/common/alloccommon.h b/third_party/libvpx/source/libvpx/vp8/common/alloccommon.h similarity index 100% rename from third_party/libvpx/vp8/common/alloccommon.h rename to third_party/libvpx/source/libvpx/vp8/common/alloccommon.h diff --git a/third_party/libvpx/vp8/common/arm/loopfilter_arm.c b/third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/loopfilter_arm.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c diff --git a/third_party/libvpx/vp8/common/arm/loopfilter_arm.h b/third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.h similarity index 100% rename from third_party/libvpx/vp8/common/arm/loopfilter_arm.h rename to third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.h diff --git a/third_party/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/copymem_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/copymem_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/dequant_idct_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/dequant_idct_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/dequantizeb_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/dequantizeb_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/idct_blk_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/idct_blk_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/iwalsh_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/iwalsh_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/sixtappredict_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/sixtappredict_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c diff --git a/third_party/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c b/third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c similarity index 100% rename from third_party/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c rename to third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c diff --git a/third_party/libvpx/vp8/common/blockd.c b/third_party/libvpx/source/libvpx/vp8/common/blockd.c similarity index 100% rename from third_party/libvpx/vp8/common/blockd.c rename to third_party/libvpx/source/libvpx/vp8/common/blockd.c diff --git a/third_party/libvpx/vp8/common/blockd.h b/third_party/libvpx/source/libvpx/vp8/common/blockd.h similarity index 100% rename from third_party/libvpx/vp8/common/blockd.h rename to third_party/libvpx/source/libvpx/vp8/common/blockd.h diff --git a/third_party/libvpx/vp8/common/coefupdateprobs.h b/third_party/libvpx/source/libvpx/vp8/common/coefupdateprobs.h similarity index 100% rename from third_party/libvpx/vp8/common/coefupdateprobs.h rename to third_party/libvpx/source/libvpx/vp8/common/coefupdateprobs.h diff --git a/third_party/libvpx/vp8/common/common.h b/third_party/libvpx/source/libvpx/vp8/common/common.h similarity index 100% rename from third_party/libvpx/vp8/common/common.h rename to third_party/libvpx/source/libvpx/vp8/common/common.h diff --git a/third_party/libvpx/vp8/common/context.c b/third_party/libvpx/source/libvpx/vp8/common/context.c similarity index 100% rename from third_party/libvpx/vp8/common/context.c rename to third_party/libvpx/source/libvpx/vp8/common/context.c diff --git a/third_party/libvpx/vp8/common/debugmodes.c b/third_party/libvpx/source/libvpx/vp8/common/debugmodes.c similarity index 100% rename from third_party/libvpx/vp8/common/debugmodes.c rename to third_party/libvpx/source/libvpx/vp8/common/debugmodes.c diff --git a/third_party/libvpx/vp8/common/default_coef_probs.h b/third_party/libvpx/source/libvpx/vp8/common/default_coef_probs.h similarity index 100% rename from third_party/libvpx/vp8/common/default_coef_probs.h rename to third_party/libvpx/source/libvpx/vp8/common/default_coef_probs.h diff --git a/third_party/libvpx/vp8/common/dequantize.c b/third_party/libvpx/source/libvpx/vp8/common/dequantize.c similarity index 100% rename from third_party/libvpx/vp8/common/dequantize.c rename to third_party/libvpx/source/libvpx/vp8/common/dequantize.c diff --git a/third_party/libvpx/vp8/common/entropy.c b/third_party/libvpx/source/libvpx/vp8/common/entropy.c similarity index 100% rename from third_party/libvpx/vp8/common/entropy.c rename to third_party/libvpx/source/libvpx/vp8/common/entropy.c diff --git a/third_party/libvpx/vp8/common/entropy.h b/third_party/libvpx/source/libvpx/vp8/common/entropy.h similarity index 100% rename from third_party/libvpx/vp8/common/entropy.h rename to third_party/libvpx/source/libvpx/vp8/common/entropy.h diff --git a/third_party/libvpx/vp8/common/entropymode.c b/third_party/libvpx/source/libvpx/vp8/common/entropymode.c similarity index 100% rename from third_party/libvpx/vp8/common/entropymode.c rename to third_party/libvpx/source/libvpx/vp8/common/entropymode.c diff --git a/third_party/libvpx/vp8/common/entropymode.h b/third_party/libvpx/source/libvpx/vp8/common/entropymode.h similarity index 100% rename from third_party/libvpx/vp8/common/entropymode.h rename to third_party/libvpx/source/libvpx/vp8/common/entropymode.h diff --git a/third_party/libvpx/vp8/common/entropymv.c b/third_party/libvpx/source/libvpx/vp8/common/entropymv.c similarity index 100% rename from third_party/libvpx/vp8/common/entropymv.c rename to third_party/libvpx/source/libvpx/vp8/common/entropymv.c diff --git a/third_party/libvpx/vp8/common/entropymv.h b/third_party/libvpx/source/libvpx/vp8/common/entropymv.h similarity index 100% rename from third_party/libvpx/vp8/common/entropymv.h rename to third_party/libvpx/source/libvpx/vp8/common/entropymv.h diff --git a/third_party/libvpx/vp8/common/extend.c b/third_party/libvpx/source/libvpx/vp8/common/extend.c similarity index 100% rename from third_party/libvpx/vp8/common/extend.c rename to third_party/libvpx/source/libvpx/vp8/common/extend.c diff --git a/third_party/libvpx/vp8/common/extend.h b/third_party/libvpx/source/libvpx/vp8/common/extend.h similarity index 100% rename from third_party/libvpx/vp8/common/extend.h rename to third_party/libvpx/source/libvpx/vp8/common/extend.h diff --git a/third_party/libvpx/vp8/common/filter.c b/third_party/libvpx/source/libvpx/vp8/common/filter.c similarity index 100% rename from third_party/libvpx/vp8/common/filter.c rename to third_party/libvpx/source/libvpx/vp8/common/filter.c diff --git a/third_party/libvpx/vp8/common/filter.h b/third_party/libvpx/source/libvpx/vp8/common/filter.h similarity index 100% rename from third_party/libvpx/vp8/common/filter.h rename to third_party/libvpx/source/libvpx/vp8/common/filter.h diff --git a/third_party/libvpx/vp8/common/findnearmv.c b/third_party/libvpx/source/libvpx/vp8/common/findnearmv.c similarity index 100% rename from third_party/libvpx/vp8/common/findnearmv.c rename to third_party/libvpx/source/libvpx/vp8/common/findnearmv.c diff --git a/third_party/libvpx/vp8/common/findnearmv.h b/third_party/libvpx/source/libvpx/vp8/common/findnearmv.h similarity index 100% rename from third_party/libvpx/vp8/common/findnearmv.h rename to third_party/libvpx/source/libvpx/vp8/common/findnearmv.h diff --git a/third_party/libvpx/vp8/common/generic/systemdependent.c b/third_party/libvpx/source/libvpx/vp8/common/generic/systemdependent.c similarity index 96% rename from third_party/libvpx/vp8/common/generic/systemdependent.c rename to third_party/libvpx/source/libvpx/vp8/common/generic/systemdependent.c index 75ce7ef35964..cd1b02c9cc5b 100644 --- a/third_party/libvpx/vp8/common/generic/systemdependent.c +++ b/third_party/libvpx/source/libvpx/vp8/common/generic/systemdependent.c @@ -16,6 +16,8 @@ #include "vpx_ports/x86.h" #elif VPX_ARCH_PPC #include "vpx_ports/ppc.h" +#elif VPX_ARCH_MIPS +#include "vpx_ports/mips.h" #endif #include "vp8/common/onyxc_int.h" #include "vp8/common/systemdependent.h" @@ -96,6 +98,8 @@ void vp8_machine_specific_config(VP8_COMMON *ctx) { ctx->cpu_caps = x86_simd_caps(); #elif VPX_ARCH_PPC ctx->cpu_caps = ppc_simd_caps(); +#elif VPX_ARCH_MIPS + ctx->cpu_caps = mips_cpu_caps(); #else // generic-gnu targets. ctx->cpu_caps = 0; diff --git a/third_party/libvpx/vp8/common/header.h b/third_party/libvpx/source/libvpx/vp8/common/header.h similarity index 100% rename from third_party/libvpx/vp8/common/header.h rename to third_party/libvpx/source/libvpx/vp8/common/header.h diff --git a/third_party/libvpx/vp8/common/idct_blk.c b/third_party/libvpx/source/libvpx/vp8/common/idct_blk.c similarity index 100% rename from third_party/libvpx/vp8/common/idct_blk.c rename to third_party/libvpx/source/libvpx/vp8/common/idct_blk.c diff --git a/third_party/libvpx/vp8/common/idctllm.c b/third_party/libvpx/source/libvpx/vp8/common/idctllm.c similarity index 100% rename from third_party/libvpx/vp8/common/idctllm.c rename to third_party/libvpx/source/libvpx/vp8/common/idctllm.c diff --git a/third_party/libvpx/vp8/common/invtrans.h b/third_party/libvpx/source/libvpx/vp8/common/invtrans.h similarity index 100% rename from third_party/libvpx/vp8/common/invtrans.h rename to third_party/libvpx/source/libvpx/vp8/common/invtrans.h diff --git a/third_party/libvpx/vp8/common/loopfilter.h b/third_party/libvpx/source/libvpx/vp8/common/loopfilter.h similarity index 100% rename from third_party/libvpx/vp8/common/loopfilter.h rename to third_party/libvpx/source/libvpx/vp8/common/loopfilter.h diff --git a/third_party/libvpx/vp8/common/loopfilter_filters.c b/third_party/libvpx/source/libvpx/vp8/common/loopfilter_filters.c similarity index 100% rename from third_party/libvpx/vp8/common/loopfilter_filters.c rename to third_party/libvpx/source/libvpx/vp8/common/loopfilter_filters.c diff --git a/third_party/libvpx/vp8/common/mbpitch.c b/third_party/libvpx/source/libvpx/vp8/common/mbpitch.c similarity index 100% rename from third_party/libvpx/vp8/common/mbpitch.c rename to third_party/libvpx/source/libvpx/vp8/common/mbpitch.c diff --git a/third_party/libvpx/vp8/common/mfqe.c b/third_party/libvpx/source/libvpx/vp8/common/mfqe.c similarity index 100% rename from third_party/libvpx/vp8/common/mfqe.c rename to third_party/libvpx/source/libvpx/vp8/common/mfqe.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/dequantize_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/dequantize_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/dequantize_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/dequantize_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/filter_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/filter_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/filter_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/filter_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/idct_blk_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/idct_blk_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/idct_blk_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/idct_blk_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/idctllm_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/idctllm_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/idctllm_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/idctllm_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/reconinter_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/reconinter_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/reconinter_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/reconinter_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/dspr2/vp8_loopfilter_filters_dspr2.c b/third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/vp8_loopfilter_filters_dspr2.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/dspr2/vp8_loopfilter_filters_dspr2.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/dspr2/vp8_loopfilter_filters_dspr2.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/copymem_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/copymem_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/copymem_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/copymem_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/dequantize_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/dequantize_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/dequantize_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/dequantize_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/idct_blk_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/idct_blk_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/idct_blk_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/idct_blk_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/idctllm_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/idctllm_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/idctllm_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/idctllm_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/loopfilter_filters_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/loopfilter_filters_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/loopfilter_filters_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/loopfilter_filters_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/mmi/sixtap_filter_mmi.c b/third_party/libvpx/source/libvpx/vp8/common/mips/mmi/sixtap_filter_mmi.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/mmi/sixtap_filter_mmi.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/mmi/sixtap_filter_mmi.c diff --git a/third_party/libvpx/vp8/common/mips/msa/bilinear_filter_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/bilinear_filter_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/bilinear_filter_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/bilinear_filter_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/copymem_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/copymem_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/copymem_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/copymem_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/idct_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/idct_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/idct_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/idct_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/mfqe_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/mfqe_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/mfqe_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/mfqe_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/sixtap_filter_msa.c b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/sixtap_filter_msa.c similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/sixtap_filter_msa.c rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/sixtap_filter_msa.c diff --git a/third_party/libvpx/vp8/common/mips/msa/vp8_macros_msa.h b/third_party/libvpx/source/libvpx/vp8/common/mips/msa/vp8_macros_msa.h similarity index 100% rename from third_party/libvpx/vp8/common/mips/msa/vp8_macros_msa.h rename to third_party/libvpx/source/libvpx/vp8/common/mips/msa/vp8_macros_msa.h diff --git a/third_party/libvpx/vp8/common/modecont.c b/third_party/libvpx/source/libvpx/vp8/common/modecont.c similarity index 100% rename from third_party/libvpx/vp8/common/modecont.c rename to third_party/libvpx/source/libvpx/vp8/common/modecont.c diff --git a/third_party/libvpx/vp8/common/modecont.h b/third_party/libvpx/source/libvpx/vp8/common/modecont.h similarity index 100% rename from third_party/libvpx/vp8/common/modecont.h rename to third_party/libvpx/source/libvpx/vp8/common/modecont.h diff --git a/third_party/libvpx/vp8/common/mv.h b/third_party/libvpx/source/libvpx/vp8/common/mv.h similarity index 100% rename from third_party/libvpx/vp8/common/mv.h rename to third_party/libvpx/source/libvpx/vp8/common/mv.h diff --git a/third_party/libvpx/vp8/common/onyx.h b/third_party/libvpx/source/libvpx/vp8/common/onyx.h similarity index 100% rename from third_party/libvpx/vp8/common/onyx.h rename to third_party/libvpx/source/libvpx/vp8/common/onyx.h diff --git a/third_party/libvpx/vp8/common/onyxc_int.h b/third_party/libvpx/source/libvpx/vp8/common/onyxc_int.h similarity index 100% rename from third_party/libvpx/vp8/common/onyxc_int.h rename to third_party/libvpx/source/libvpx/vp8/common/onyxc_int.h diff --git a/third_party/libvpx/vp8/common/onyxd.h b/third_party/libvpx/source/libvpx/vp8/common/onyxd.h similarity index 100% rename from third_party/libvpx/vp8/common/onyxd.h rename to third_party/libvpx/source/libvpx/vp8/common/onyxd.h diff --git a/third_party/libvpx/vp8/common/postproc.c b/third_party/libvpx/source/libvpx/vp8/common/postproc.c similarity index 100% rename from third_party/libvpx/vp8/common/postproc.c rename to third_party/libvpx/source/libvpx/vp8/common/postproc.c diff --git a/third_party/libvpx/vp8/common/postproc.h b/third_party/libvpx/source/libvpx/vp8/common/postproc.h similarity index 100% rename from third_party/libvpx/vp8/common/postproc.h rename to third_party/libvpx/source/libvpx/vp8/common/postproc.h diff --git a/third_party/libvpx/vp8/common/ppflags.h b/third_party/libvpx/source/libvpx/vp8/common/ppflags.h similarity index 100% rename from third_party/libvpx/vp8/common/ppflags.h rename to third_party/libvpx/source/libvpx/vp8/common/ppflags.h diff --git a/third_party/libvpx/vp8/common/quant_common.c b/third_party/libvpx/source/libvpx/vp8/common/quant_common.c similarity index 100% rename from third_party/libvpx/vp8/common/quant_common.c rename to third_party/libvpx/source/libvpx/vp8/common/quant_common.c diff --git a/third_party/libvpx/vp8/common/quant_common.h b/third_party/libvpx/source/libvpx/vp8/common/quant_common.h similarity index 100% rename from third_party/libvpx/vp8/common/quant_common.h rename to third_party/libvpx/source/libvpx/vp8/common/quant_common.h diff --git a/third_party/libvpx/vp8/common/reconinter.c b/third_party/libvpx/source/libvpx/vp8/common/reconinter.c similarity index 100% rename from third_party/libvpx/vp8/common/reconinter.c rename to third_party/libvpx/source/libvpx/vp8/common/reconinter.c diff --git a/third_party/libvpx/vp8/common/reconinter.h b/third_party/libvpx/source/libvpx/vp8/common/reconinter.h similarity index 100% rename from third_party/libvpx/vp8/common/reconinter.h rename to third_party/libvpx/source/libvpx/vp8/common/reconinter.h diff --git a/third_party/libvpx/vp8/common/reconintra.c b/third_party/libvpx/source/libvpx/vp8/common/reconintra.c similarity index 100% rename from third_party/libvpx/vp8/common/reconintra.c rename to third_party/libvpx/source/libvpx/vp8/common/reconintra.c diff --git a/third_party/libvpx/vp8/common/reconintra.h b/third_party/libvpx/source/libvpx/vp8/common/reconintra.h similarity index 100% rename from third_party/libvpx/vp8/common/reconintra.h rename to third_party/libvpx/source/libvpx/vp8/common/reconintra.h diff --git a/third_party/libvpx/vp8/common/reconintra4x4.c b/third_party/libvpx/source/libvpx/vp8/common/reconintra4x4.c similarity index 100% rename from third_party/libvpx/vp8/common/reconintra4x4.c rename to third_party/libvpx/source/libvpx/vp8/common/reconintra4x4.c diff --git a/third_party/libvpx/vp8/common/reconintra4x4.h b/third_party/libvpx/source/libvpx/vp8/common/reconintra4x4.h similarity index 100% rename from third_party/libvpx/vp8/common/reconintra4x4.h rename to third_party/libvpx/source/libvpx/vp8/common/reconintra4x4.h diff --git a/third_party/libvpx/vp8/common/rtcd.c b/third_party/libvpx/source/libvpx/vp8/common/rtcd.c similarity index 100% rename from third_party/libvpx/vp8/common/rtcd.c rename to third_party/libvpx/source/libvpx/vp8/common/rtcd.c diff --git a/third_party/libvpx/vp8/common/rtcd_defs.pl b/third_party/libvpx/source/libvpx/vp8/common/rtcd_defs.pl similarity index 100% rename from third_party/libvpx/vp8/common/rtcd_defs.pl rename to third_party/libvpx/source/libvpx/vp8/common/rtcd_defs.pl diff --git a/third_party/libvpx/vp8/common/setupintrarecon.c b/third_party/libvpx/source/libvpx/vp8/common/setupintrarecon.c similarity index 100% rename from third_party/libvpx/vp8/common/setupintrarecon.c rename to third_party/libvpx/source/libvpx/vp8/common/setupintrarecon.c diff --git a/third_party/libvpx/vp8/common/setupintrarecon.h b/third_party/libvpx/source/libvpx/vp8/common/setupintrarecon.h similarity index 100% rename from third_party/libvpx/vp8/common/setupintrarecon.h rename to third_party/libvpx/source/libvpx/vp8/common/setupintrarecon.h diff --git a/third_party/libvpx/vp8/common/swapyv12buffer.c b/third_party/libvpx/source/libvpx/vp8/common/swapyv12buffer.c similarity index 100% rename from third_party/libvpx/vp8/common/swapyv12buffer.c rename to third_party/libvpx/source/libvpx/vp8/common/swapyv12buffer.c diff --git a/third_party/libvpx/vp8/common/swapyv12buffer.h b/third_party/libvpx/source/libvpx/vp8/common/swapyv12buffer.h similarity index 100% rename from third_party/libvpx/vp8/common/swapyv12buffer.h rename to third_party/libvpx/source/libvpx/vp8/common/swapyv12buffer.h diff --git a/third_party/libvpx/vp8/common/systemdependent.h b/third_party/libvpx/source/libvpx/vp8/common/systemdependent.h similarity index 100% rename from third_party/libvpx/vp8/common/systemdependent.h rename to third_party/libvpx/source/libvpx/vp8/common/systemdependent.h diff --git a/third_party/libvpx/vp8/common/threading.h b/third_party/libvpx/source/libvpx/vp8/common/threading.h similarity index 97% rename from third_party/libvpx/vp8/common/threading.h rename to third_party/libvpx/source/libvpx/vp8/common/threading.h index f9213693864e..1cfb9fec5154 100644 --- a/third_party/libvpx/vp8/common/threading.h +++ b/third_party/libvpx/source/libvpx/vp8/common/threading.h @@ -171,17 +171,20 @@ static inline int sem_destroy(sem_t *sem) { #define sem_wait(sem) (semaphore_wait(*sem)) #define sem_post(sem) semaphore_signal(*sem) #define sem_destroy(sem) semaphore_destroy(mach_task_self(), *sem) -#define thread_sleep(nms) -/* { struct timespec ts;ts.tv_sec=0; ts.tv_nsec = - 1000*nms;nanosleep(&ts, NULL);} */ #else #include #include -#define thread_sleep(nms) sched_yield(); +#endif /* __APPLE__ */ +/* Not Windows. Assume pthreads */ + +/* thread_sleep implementation: yield unless Linux/Unix. */ +#if defined(__unix__) || defined(__APPLE__) +#define thread_sleep(nms) /* {struct timespec ts;ts.tv_sec=0; ts.tv_nsec = 1000*nms;nanosleep(&ts, NULL);} */ -#endif -/* Not Windows. Assume pthreads */ +#else +#define thread_sleep(nms) sched_yield(); +#endif /* __unix__ || __APPLE__ */ #endif diff --git a/third_party/libvpx/vp8/common/treecoder.c b/third_party/libvpx/source/libvpx/vp8/common/treecoder.c similarity index 100% rename from third_party/libvpx/vp8/common/treecoder.c rename to third_party/libvpx/source/libvpx/vp8/common/treecoder.c diff --git a/third_party/libvpx/vp8/common/treecoder.h b/third_party/libvpx/source/libvpx/vp8/common/treecoder.h similarity index 100% rename from third_party/libvpx/vp8/common/treecoder.h rename to third_party/libvpx/source/libvpx/vp8/common/treecoder.h diff --git a/third_party/libvpx/vp8/common/vp8_entropymodedata.h b/third_party/libvpx/source/libvpx/vp8/common/vp8_entropymodedata.h similarity index 100% rename from third_party/libvpx/vp8/common/vp8_entropymodedata.h rename to third_party/libvpx/source/libvpx/vp8/common/vp8_entropymodedata.h diff --git a/third_party/libvpx/vp8/common/vp8_loopfilter.c b/third_party/libvpx/source/libvpx/vp8/common/vp8_loopfilter.c similarity index 100% rename from third_party/libvpx/vp8/common/vp8_loopfilter.c rename to third_party/libvpx/source/libvpx/vp8/common/vp8_loopfilter.c diff --git a/third_party/libvpx/vp8/common/vp8_skin_detection.c b/third_party/libvpx/source/libvpx/vp8/common/vp8_skin_detection.c similarity index 100% rename from third_party/libvpx/vp8/common/vp8_skin_detection.c rename to third_party/libvpx/source/libvpx/vp8/common/vp8_skin_detection.c diff --git a/third_party/libvpx/vp8/common/vp8_skin_detection.h b/third_party/libvpx/source/libvpx/vp8/common/vp8_skin_detection.h similarity index 100% rename from third_party/libvpx/vp8/common/vp8_skin_detection.h rename to third_party/libvpx/source/libvpx/vp8/common/vp8_skin_detection.h diff --git a/third_party/libvpx/vp8/common/x86/bilinear_filter_sse2.c b/third_party/libvpx/source/libvpx/vp8/common/x86/bilinear_filter_sse2.c similarity index 100% rename from third_party/libvpx/vp8/common/x86/bilinear_filter_sse2.c rename to third_party/libvpx/source/libvpx/vp8/common/x86/bilinear_filter_sse2.c diff --git a/third_party/libvpx/vp8/common/x86/dequantize_mmx.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/dequantize_mmx.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/dequantize_mmx.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/dequantize_mmx.asm diff --git a/third_party/libvpx/vp8/common/x86/idct_blk_mmx.c b/third_party/libvpx/source/libvpx/vp8/common/x86/idct_blk_mmx.c similarity index 100% rename from third_party/libvpx/vp8/common/x86/idct_blk_mmx.c rename to third_party/libvpx/source/libvpx/vp8/common/x86/idct_blk_mmx.c diff --git a/third_party/libvpx/vp8/common/x86/idct_blk_sse2.c b/third_party/libvpx/source/libvpx/vp8/common/x86/idct_blk_sse2.c similarity index 100% rename from third_party/libvpx/vp8/common/x86/idct_blk_sse2.c rename to third_party/libvpx/source/libvpx/vp8/common/x86/idct_blk_sse2.c diff --git a/third_party/libvpx/vp8/common/x86/idctllm_mmx.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/idctllm_mmx.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/idctllm_mmx.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/idctllm_mmx.asm diff --git a/third_party/libvpx/vp8/common/x86/idctllm_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/idctllm_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/idctllm_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/idctllm_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/iwalsh_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/iwalsh_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/iwalsh_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/iwalsh_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/loopfilter_block_sse2_x86_64.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_block_sse2_x86_64.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/loopfilter_block_sse2_x86_64.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_block_sse2_x86_64.asm diff --git a/third_party/libvpx/vp8/common/x86/loopfilter_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/loopfilter_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/loopfilter_x86.c b/third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_x86.c similarity index 100% rename from third_party/libvpx/vp8/common/x86/loopfilter_x86.c rename to third_party/libvpx/source/libvpx/vp8/common/x86/loopfilter_x86.c diff --git a/third_party/libvpx/vp8/common/x86/mfqe_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/mfqe_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/mfqe_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/mfqe_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/recon_mmx.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/recon_mmx.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/recon_mmx.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/recon_mmx.asm diff --git a/third_party/libvpx/vp8/common/x86/recon_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/recon_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/recon_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/recon_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/subpixel_mmx.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_mmx.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/subpixel_mmx.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_mmx.asm diff --git a/third_party/libvpx/vp8/common/x86/subpixel_sse2.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/subpixel_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_sse2.asm diff --git a/third_party/libvpx/vp8/common/x86/subpixel_ssse3.asm b/third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_ssse3.asm similarity index 100% rename from third_party/libvpx/vp8/common/x86/subpixel_ssse3.asm rename to third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_ssse3.asm diff --git a/third_party/libvpx/vp8/common/x86/vp8_asm_stubs.c b/third_party/libvpx/source/libvpx/vp8/common/x86/vp8_asm_stubs.c similarity index 100% rename from third_party/libvpx/vp8/common/x86/vp8_asm_stubs.c rename to third_party/libvpx/source/libvpx/vp8/common/x86/vp8_asm_stubs.c diff --git a/third_party/libvpx/vp8/decoder/dboolhuff.c b/third_party/libvpx/source/libvpx/vp8/decoder/dboolhuff.c similarity index 100% rename from third_party/libvpx/vp8/decoder/dboolhuff.c rename to third_party/libvpx/source/libvpx/vp8/decoder/dboolhuff.c diff --git a/third_party/libvpx/vp8/decoder/dboolhuff.h b/third_party/libvpx/source/libvpx/vp8/decoder/dboolhuff.h similarity index 100% rename from third_party/libvpx/vp8/decoder/dboolhuff.h rename to third_party/libvpx/source/libvpx/vp8/decoder/dboolhuff.h diff --git a/third_party/libvpx/vp8/decoder/decodeframe.c b/third_party/libvpx/source/libvpx/vp8/decoder/decodeframe.c similarity index 100% rename from third_party/libvpx/vp8/decoder/decodeframe.c rename to third_party/libvpx/source/libvpx/vp8/decoder/decodeframe.c diff --git a/third_party/libvpx/vp8/decoder/decodemv.c b/third_party/libvpx/source/libvpx/vp8/decoder/decodemv.c similarity index 100% rename from third_party/libvpx/vp8/decoder/decodemv.c rename to third_party/libvpx/source/libvpx/vp8/decoder/decodemv.c diff --git a/third_party/libvpx/vp8/decoder/decodemv.h b/third_party/libvpx/source/libvpx/vp8/decoder/decodemv.h similarity index 100% rename from third_party/libvpx/vp8/decoder/decodemv.h rename to third_party/libvpx/source/libvpx/vp8/decoder/decodemv.h diff --git a/third_party/libvpx/vp8/decoder/decoderthreading.h b/third_party/libvpx/source/libvpx/vp8/decoder/decoderthreading.h similarity index 100% rename from third_party/libvpx/vp8/decoder/decoderthreading.h rename to third_party/libvpx/source/libvpx/vp8/decoder/decoderthreading.h diff --git a/third_party/libvpx/vp8/decoder/detokenize.c b/third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c similarity index 100% rename from third_party/libvpx/vp8/decoder/detokenize.c rename to third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c diff --git a/third_party/libvpx/vp8/decoder/detokenize.h b/third_party/libvpx/source/libvpx/vp8/decoder/detokenize.h similarity index 100% rename from third_party/libvpx/vp8/decoder/detokenize.h rename to third_party/libvpx/source/libvpx/vp8/decoder/detokenize.h diff --git a/third_party/libvpx/vp8/decoder/ec_types.h b/third_party/libvpx/source/libvpx/vp8/decoder/ec_types.h similarity index 100% rename from third_party/libvpx/vp8/decoder/ec_types.h rename to third_party/libvpx/source/libvpx/vp8/decoder/ec_types.h diff --git a/third_party/libvpx/vp8/decoder/error_concealment.c b/third_party/libvpx/source/libvpx/vp8/decoder/error_concealment.c similarity index 100% rename from third_party/libvpx/vp8/decoder/error_concealment.c rename to third_party/libvpx/source/libvpx/vp8/decoder/error_concealment.c diff --git a/third_party/libvpx/vp8/decoder/error_concealment.h b/third_party/libvpx/source/libvpx/vp8/decoder/error_concealment.h similarity index 100% rename from third_party/libvpx/vp8/decoder/error_concealment.h rename to third_party/libvpx/source/libvpx/vp8/decoder/error_concealment.h diff --git a/third_party/libvpx/vp8/decoder/onyxd_if.c b/third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c similarity index 100% rename from third_party/libvpx/vp8/decoder/onyxd_if.c rename to third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c diff --git a/third_party/libvpx/vp8/decoder/onyxd_int.h b/third_party/libvpx/source/libvpx/vp8/decoder/onyxd_int.h similarity index 100% rename from third_party/libvpx/vp8/decoder/onyxd_int.h rename to third_party/libvpx/source/libvpx/vp8/decoder/onyxd_int.h diff --git a/third_party/libvpx/vp8/decoder/threading.c b/third_party/libvpx/source/libvpx/vp8/decoder/threading.c similarity index 99% rename from third_party/libvpx/vp8/decoder/threading.c rename to third_party/libvpx/source/libvpx/vp8/decoder/threading.c index 561922de3296..491e2ce4c166 100644 --- a/third_party/libvpx/vp8/decoder/threading.c +++ b/third_party/libvpx/source/libvpx/vp8/decoder/threading.c @@ -10,7 +10,7 @@ #include "vpx_config.h" #include "vp8_rtcd.h" -#if !defined(WIN32) && CONFIG_OS_SUPPORT == 1 +#if !defined(_WIN32) && CONFIG_OS_SUPPORT == 1 #include #endif #include "onyxd_int.h" diff --git a/third_party/libvpx/vp8/decoder/treereader.h b/third_party/libvpx/source/libvpx/vp8/decoder/treereader.h similarity index 100% rename from third_party/libvpx/vp8/decoder/treereader.h rename to third_party/libvpx/source/libvpx/vp8/decoder/treereader.h diff --git a/third_party/libvpx/vp8/encoder/arm/neon/denoising_neon.c b/third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c similarity index 100% rename from third_party/libvpx/vp8/encoder/arm/neon/denoising_neon.c rename to third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c diff --git a/third_party/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c b/third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c similarity index 100% rename from third_party/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c rename to third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c diff --git a/third_party/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c b/third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c similarity index 100% rename from third_party/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c rename to third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c diff --git a/third_party/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c b/third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c similarity index 100% rename from third_party/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c rename to third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c diff --git a/third_party/libvpx/vp8/encoder/bitstream.c b/third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c similarity index 99% rename from third_party/libvpx/vp8/encoder/bitstream.c rename to third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c index 80cbb882fdcd..87825fa6febe 100644 --- a/third_party/libvpx/vp8/encoder/bitstream.c +++ b/third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c @@ -866,7 +866,6 @@ void vp8_update_coef_probs(VP8_COMP *cpi) { #if !(CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) vp8_writer *const w = cpi->bc; #endif - int savings = 0; vpx_clear_system_state(); @@ -940,8 +939,6 @@ void vp8_update_coef_probs(VP8_COMP *cpi) { #if !(CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) vp8_write_literal(w, newp, 8); #endif - - savings += s; } } while (++t < ENTROPY_NODES); diff --git a/third_party/libvpx/vp8/encoder/bitstream.h b/third_party/libvpx/source/libvpx/vp8/encoder/bitstream.h similarity index 100% rename from third_party/libvpx/vp8/encoder/bitstream.h rename to third_party/libvpx/source/libvpx/vp8/encoder/bitstream.h diff --git a/third_party/libvpx/vp8/encoder/block.h b/third_party/libvpx/source/libvpx/vp8/encoder/block.h similarity index 100% rename from third_party/libvpx/vp8/encoder/block.h rename to third_party/libvpx/source/libvpx/vp8/encoder/block.h diff --git a/third_party/libvpx/vp8/encoder/boolhuff.c b/third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c similarity index 100% rename from third_party/libvpx/vp8/encoder/boolhuff.c rename to third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c diff --git a/third_party/libvpx/vp8/encoder/boolhuff.h b/third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.h similarity index 100% rename from third_party/libvpx/vp8/encoder/boolhuff.h rename to third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.h diff --git a/third_party/libvpx/vp8/encoder/copy_c.c b/third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c similarity index 100% rename from third_party/libvpx/vp8/encoder/copy_c.c rename to third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c diff --git a/third_party/libvpx/vp8/encoder/dct.c b/third_party/libvpx/source/libvpx/vp8/encoder/dct.c similarity index 100% rename from third_party/libvpx/vp8/encoder/dct.c rename to third_party/libvpx/source/libvpx/vp8/encoder/dct.c diff --git a/third_party/libvpx/vp8/encoder/dct_value_cost.h b/third_party/libvpx/source/libvpx/vp8/encoder/dct_value_cost.h similarity index 100% rename from third_party/libvpx/vp8/encoder/dct_value_cost.h rename to third_party/libvpx/source/libvpx/vp8/encoder/dct_value_cost.h diff --git a/third_party/libvpx/vp8/encoder/dct_value_tokens.h b/third_party/libvpx/source/libvpx/vp8/encoder/dct_value_tokens.h similarity index 100% rename from third_party/libvpx/vp8/encoder/dct_value_tokens.h rename to third_party/libvpx/source/libvpx/vp8/encoder/dct_value_tokens.h diff --git a/third_party/libvpx/vp8/encoder/defaultcoefcounts.h b/third_party/libvpx/source/libvpx/vp8/encoder/defaultcoefcounts.h similarity index 100% rename from third_party/libvpx/vp8/encoder/defaultcoefcounts.h rename to third_party/libvpx/source/libvpx/vp8/encoder/defaultcoefcounts.h diff --git a/third_party/libvpx/vp8/encoder/denoising.c b/third_party/libvpx/source/libvpx/vp8/encoder/denoising.c similarity index 100% rename from third_party/libvpx/vp8/encoder/denoising.c rename to third_party/libvpx/source/libvpx/vp8/encoder/denoising.c diff --git a/third_party/libvpx/vp8/encoder/denoising.h b/third_party/libvpx/source/libvpx/vp8/encoder/denoising.h similarity index 100% rename from third_party/libvpx/vp8/encoder/denoising.h rename to third_party/libvpx/source/libvpx/vp8/encoder/denoising.h diff --git a/third_party/libvpx/vp8/encoder/encodeframe.c b/third_party/libvpx/source/libvpx/vp8/encoder/encodeframe.c similarity index 99% rename from third_party/libvpx/vp8/encoder/encodeframe.c rename to third_party/libvpx/source/libvpx/vp8/encoder/encodeframe.c index 2b3d9564ce20..2f84381d24f9 100644 --- a/third_party/libvpx/vp8/encoder/encodeframe.c +++ b/third_party/libvpx/source/libvpx/vp8/encoder/encodeframe.c @@ -343,8 +343,11 @@ static void encode_mb_row(VP8_COMP *cpi, VP8_COMMON *cm, int mb_row, const int nsync = cpi->mt_sync_range; vpx_atomic_int rightmost_col = VPX_ATOMIC_INIT(cm->mb_cols + nsync); const vpx_atomic_int *last_row_current_mb_col; - vpx_atomic_int *current_mb_col = &cpi->mt_current_mb_col[mb_row]; + vpx_atomic_int *current_mb_col = NULL; + if (vpx_atomic_load_acquire(&cpi->b_multi_threaded) != 0) { + current_mb_col = &cpi->mt_current_mb_col[mb_row]; + } if (vpx_atomic_load_acquire(&cpi->b_multi_threaded) != 0 && mb_row != 0) { last_row_current_mb_col = &cpi->mt_current_mb_col[mb_row - 1]; } else { diff --git a/third_party/libvpx/vp8/encoder/encodeframe.h b/third_party/libvpx/source/libvpx/vp8/encoder/encodeframe.h similarity index 100% rename from third_party/libvpx/vp8/encoder/encodeframe.h rename to third_party/libvpx/source/libvpx/vp8/encoder/encodeframe.h diff --git a/third_party/libvpx/vp8/encoder/encodeintra.c b/third_party/libvpx/source/libvpx/vp8/encoder/encodeintra.c similarity index 100% rename from third_party/libvpx/vp8/encoder/encodeintra.c rename to third_party/libvpx/source/libvpx/vp8/encoder/encodeintra.c diff --git a/third_party/libvpx/vp8/encoder/encodeintra.h b/third_party/libvpx/source/libvpx/vp8/encoder/encodeintra.h similarity index 100% rename from third_party/libvpx/vp8/encoder/encodeintra.h rename to third_party/libvpx/source/libvpx/vp8/encoder/encodeintra.h diff --git a/third_party/libvpx/vp8/encoder/encodemb.c b/third_party/libvpx/source/libvpx/vp8/encoder/encodemb.c similarity index 100% rename from third_party/libvpx/vp8/encoder/encodemb.c rename to third_party/libvpx/source/libvpx/vp8/encoder/encodemb.c diff --git a/third_party/libvpx/vp8/encoder/encodemb.h b/third_party/libvpx/source/libvpx/vp8/encoder/encodemb.h similarity index 100% rename from third_party/libvpx/vp8/encoder/encodemb.h rename to third_party/libvpx/source/libvpx/vp8/encoder/encodemb.h diff --git a/third_party/libvpx/vp8/encoder/encodemv.c b/third_party/libvpx/source/libvpx/vp8/encoder/encodemv.c similarity index 100% rename from third_party/libvpx/vp8/encoder/encodemv.c rename to third_party/libvpx/source/libvpx/vp8/encoder/encodemv.c diff --git a/third_party/libvpx/vp8/encoder/encodemv.h b/third_party/libvpx/source/libvpx/vp8/encoder/encodemv.h similarity index 100% rename from third_party/libvpx/vp8/encoder/encodemv.h rename to third_party/libvpx/source/libvpx/vp8/encoder/encodemv.h diff --git a/third_party/libvpx/vp8/encoder/ethreading.c b/third_party/libvpx/source/libvpx/vp8/encoder/ethreading.c similarity index 100% rename from third_party/libvpx/vp8/encoder/ethreading.c rename to third_party/libvpx/source/libvpx/vp8/encoder/ethreading.c diff --git a/third_party/libvpx/vp8/encoder/ethreading.h b/third_party/libvpx/source/libvpx/vp8/encoder/ethreading.h similarity index 100% rename from third_party/libvpx/vp8/encoder/ethreading.h rename to third_party/libvpx/source/libvpx/vp8/encoder/ethreading.h diff --git a/third_party/libvpx/vp8/encoder/firstpass.c b/third_party/libvpx/source/libvpx/vp8/encoder/firstpass.c similarity index 100% rename from third_party/libvpx/vp8/encoder/firstpass.c rename to third_party/libvpx/source/libvpx/vp8/encoder/firstpass.c diff --git a/third_party/libvpx/vp8/encoder/firstpass.h b/third_party/libvpx/source/libvpx/vp8/encoder/firstpass.h similarity index 100% rename from third_party/libvpx/vp8/encoder/firstpass.h rename to third_party/libvpx/source/libvpx/vp8/encoder/firstpass.h diff --git a/third_party/libvpx/vp8/encoder/lookahead.c b/third_party/libvpx/source/libvpx/vp8/encoder/lookahead.c similarity index 100% rename from third_party/libvpx/vp8/encoder/lookahead.c rename to third_party/libvpx/source/libvpx/vp8/encoder/lookahead.c diff --git a/third_party/libvpx/vp8/encoder/lookahead.h b/third_party/libvpx/source/libvpx/vp8/encoder/lookahead.h similarity index 100% rename from third_party/libvpx/vp8/encoder/lookahead.h rename to third_party/libvpx/source/libvpx/vp8/encoder/lookahead.h diff --git a/third_party/libvpx/vp8/encoder/mcomp.c b/third_party/libvpx/source/libvpx/vp8/encoder/mcomp.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mcomp.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mcomp.c diff --git a/third_party/libvpx/vp8/encoder/mcomp.h b/third_party/libvpx/source/libvpx/vp8/encoder/mcomp.h similarity index 100% rename from third_party/libvpx/vp8/encoder/mcomp.h rename to third_party/libvpx/source/libvpx/vp8/encoder/mcomp.h diff --git a/third_party/libvpx/vp8/encoder/mips/mmi/dct_mmi.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/mmi/dct_mmi.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/mmi/dct_mmi.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/mmi/dct_mmi.c diff --git a/third_party/libvpx/vp8/encoder/mips/mmi/vp8_quantize_mmi.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/mmi/vp8_quantize_mmi.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/mmi/vp8_quantize_mmi.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/mmi/vp8_quantize_mmi.c diff --git a/third_party/libvpx/vp8/encoder/mips/msa/dct_msa.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/dct_msa.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/msa/dct_msa.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/dct_msa.c diff --git a/third_party/libvpx/vp8/encoder/mips/msa/denoising_msa.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/denoising_msa.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/msa/denoising_msa.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/denoising_msa.c diff --git a/third_party/libvpx/vp8/encoder/mips/msa/encodeopt_msa.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/encodeopt_msa.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/msa/encodeopt_msa.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/encodeopt_msa.c diff --git a/third_party/libvpx/vp8/encoder/mips/msa/quantize_msa.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/quantize_msa.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/msa/quantize_msa.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/quantize_msa.c diff --git a/third_party/libvpx/vp8/encoder/mips/msa/temporal_filter_msa.c b/third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/temporal_filter_msa.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mips/msa/temporal_filter_msa.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mips/msa/temporal_filter_msa.c diff --git a/third_party/libvpx/vp8/encoder/modecosts.c b/third_party/libvpx/source/libvpx/vp8/encoder/modecosts.c similarity index 100% rename from third_party/libvpx/vp8/encoder/modecosts.c rename to third_party/libvpx/source/libvpx/vp8/encoder/modecosts.c diff --git a/third_party/libvpx/vp8/encoder/modecosts.h b/third_party/libvpx/source/libvpx/vp8/encoder/modecosts.h similarity index 100% rename from third_party/libvpx/vp8/encoder/modecosts.h rename to third_party/libvpx/source/libvpx/vp8/encoder/modecosts.h diff --git a/third_party/libvpx/vp8/encoder/mr_dissim.c b/third_party/libvpx/source/libvpx/vp8/encoder/mr_dissim.c similarity index 100% rename from third_party/libvpx/vp8/encoder/mr_dissim.c rename to third_party/libvpx/source/libvpx/vp8/encoder/mr_dissim.c diff --git a/third_party/libvpx/vp8/encoder/mr_dissim.h b/third_party/libvpx/source/libvpx/vp8/encoder/mr_dissim.h similarity index 100% rename from third_party/libvpx/vp8/encoder/mr_dissim.h rename to third_party/libvpx/source/libvpx/vp8/encoder/mr_dissim.h diff --git a/third_party/libvpx/vp8/encoder/onyx_if.c b/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c similarity index 98% rename from third_party/libvpx/vp8/encoder/onyx_if.c rename to third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c index aeed719d1fb1..15c9d72f5d62 100644 --- a/third_party/libvpx/vp8/encoder/onyx_if.c +++ b/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c @@ -183,7 +183,7 @@ static const unsigned char inter_minq[QINDEX_RANGE] = { extern FILE *vpxlogc; #endif -static void save_layer_context(VP8_COMP *cpi) { +void vp8_save_layer_context(VP8_COMP *cpi) { LAYER_CONTEXT *lc = &cpi->layer_context[cpi->current_layer]; /* Save layer dependent coding state */ @@ -222,7 +222,7 @@ static void save_layer_context(VP8_COMP *cpi) { sizeof(cpi->mb.count_mb_ref_frame_usage)); } -static void restore_layer_context(VP8_COMP *cpi, const int layer) { +void vp8_restore_layer_context(VP8_COMP *cpi, const int layer) { LAYER_CONTEXT *lc = &cpi->layer_context[layer]; /* Restore layer dependent coding state */ @@ -269,9 +269,9 @@ static int rescale(int val, int num, int denom) { return (int)(llval * llnum / llden); } -static void init_temporal_layer_context(VP8_COMP *cpi, VP8_CONFIG *oxcf, - const int layer, - double prev_layer_framerate) { +void vp8_init_temporal_layer_context(VP8_COMP *cpi, VP8_CONFIG *oxcf, + const int layer, + double prev_layer_framerate) { LAYER_CONTEXT *lc = &cpi->layer_context[layer]; lc->framerate = cpi->output_framerate / cpi->oxcf.rate_decimator[layer]; @@ -301,9 +301,9 @@ static void init_temporal_layer_context(VP8_COMP *cpi, VP8_CONFIG *oxcf, /* Work out the average size of a frame within this layer */ if (layer > 0) { lc->avg_frame_size_for_layer = - (int)((cpi->oxcf.target_bitrate[layer] - - cpi->oxcf.target_bitrate[layer - 1]) * - 1000 / (lc->framerate - prev_layer_framerate)); + (int)round((cpi->oxcf.target_bitrate[layer] - + cpi->oxcf.target_bitrate[layer - 1]) * + 1000 / (lc->framerate - prev_layer_framerate)); } lc->active_worst_quality = cpi->oxcf.worst_allowed_q; @@ -336,12 +336,12 @@ static void reset_temporal_layer_change(VP8_COMP *cpi, VP8_CONFIG *oxcf, // We need this to set the layer context for the new layers below. if (prev_num_layers == 1) { cpi->current_layer = 0; - save_layer_context(cpi); + vp8_save_layer_context(cpi); } for (i = 0; i < curr_num_layers; ++i) { LAYER_CONTEXT *lc = &cpi->layer_context[i]; if (i >= prev_num_layers) { - init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate); + vp8_init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate); } // The initial buffer levels are set based on their starting levels. // We could set the buffer levels based on the previous state (normalized @@ -356,7 +356,7 @@ static void reset_temporal_layer_change(VP8_COMP *cpi, VP8_CONFIG *oxcf, // state (to smooth-out quality dips/rate fluctuation at transition)? // We need to treat the 1 layer case separately: oxcf.target_bitrate[i] - // is not set for 1 layer, and the restore_layer_context/save_context() + // is not set for 1 layer, and the vp8_restore_layer_context/save_context() // are not called in the encoding loop, so we need to call it here to // pass the layer context state to |cpi|. if (curr_num_layers == 1) { @@ -364,7 +364,7 @@ static void reset_temporal_layer_change(VP8_COMP *cpi, VP8_CONFIG *oxcf, lc->buffer_level = cpi->oxcf.starting_buffer_level_in_ms * lc->target_bandwidth / 1000; lc->bits_off_target = lc->buffer_level; - restore_layer_context(cpi, 0); + vp8_restore_layer_context(cpi, 0); } prev_layer_framerate = cpi->output_framerate / cpi->oxcf.rate_decimator[i]; } @@ -1274,7 +1274,7 @@ void vp8_new_framerate(VP8_COMP *cpi, double framerate) { cpi->framerate = framerate; cpi->output_framerate = framerate; cpi->per_frame_bandwidth = - (int)(cpi->oxcf.target_bandwidth / cpi->output_framerate); + (int)round(cpi->oxcf.target_bandwidth / cpi->output_framerate); cpi->av_per_frame_bandwidth = cpi->per_frame_bandwidth; cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100); @@ -1365,7 +1365,7 @@ static void init_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) { double prev_layer_framerate = 0; for (i = 0; i < cpi->oxcf.number_of_layers; ++i) { - init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate); + vp8_init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate); prev_layer_framerate = cpi->output_framerate / cpi->oxcf.rate_decimator[i]; } @@ -1382,7 +1382,7 @@ static void init_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) { #endif } -static void update_layer_contexts(VP8_COMP *cpi) { +void vp8_update_layer_contexts(VP8_COMP *cpi) { VP8_CONFIG *oxcf = &cpi->oxcf; /* Update snapshots of the layer contexts to reflect new parameters */ @@ -1417,8 +1417,8 @@ static void update_layer_contexts(VP8_COMP *cpi) { /* Work out the average size of a frame within this layer */ if (i > 0) { lc->avg_frame_size_for_layer = - (int)((oxcf->target_bitrate[i] - oxcf->target_bitrate[i - 1]) * - 1000 / (lc->framerate - prev_layer_framerate)); + (int)round((oxcf->target_bitrate[i] - oxcf->target_bitrate[i - 1]) * + 1000 / (lc->framerate - prev_layer_framerate)); } prev_layer_framerate = lc->framerate; @@ -1910,6 +1910,7 @@ struct VP8_COMP *vp8_create_compressor(VP8_CONFIG *oxcf) { cpi->force_maxqp = 0; cpi->frames_since_last_drop_overshoot = 0; + cpi->rt_always_update_correction_factor = 0; cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; #if CONFIG_INTERNAL_STATS @@ -3260,7 +3261,7 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, #endif // !CONFIG_REALTIME_ONLY default: cpi->per_frame_bandwidth = - (int)(cpi->target_bandwidth / cpi->output_framerate); + (int)round(cpi->target_bandwidth / cpi->output_framerate); break; } @@ -3480,7 +3481,7 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, * Note that dropping a key frame can be problematic if spatial * resampling is also active */ - if (cpi->decimation_factor > 0) { + if (cpi->decimation_factor > 0 && cpi->drop_frames_allowed) { switch (cpi->decimation_factor) { case 1: cpi->per_frame_bandwidth = cpi->per_frame_bandwidth * 3 / 2; @@ -4016,7 +4017,8 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, if (frame_over_shoot_limit == 0) frame_over_shoot_limit = 1; /* Are we are overshooting and up against the limit of active max Q. */ - if (((cpi->pass != 2) || + if (!cpi->rt_always_update_correction_factor && + ((cpi->pass != 2) || (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)) && (Q == cpi->active_worst_quality) && (cpi->active_worst_quality < cpi->worst_quality) && @@ -4514,10 +4516,10 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, cpi->bits_off_target = cpi->oxcf.maximum_buffer_size; } - // If the frame dropper is not enabled, don't let the buffer level go below - // some threshold, given here by -|maximum_buffer_size|. For now we only do - // this for screen content input. - if (cpi->drop_frames_allowed == 0 && cpi->oxcf.screen_content_mode && + // Don't let the buffer level go below some threshold, given here + // by -|maximum_buffer_size|. For now we only do this for + // screen content input. + if (cpi->oxcf.screen_content_mode && cpi->bits_off_target < -cpi->oxcf.maximum_buffer_size) { cpi->bits_off_target = -cpi->oxcf.maximum_buffer_size; } @@ -4552,8 +4554,8 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, for (i = cpi->current_layer + 1; i < cpi->oxcf.number_of_layers; ++i) { LAYER_CONTEXT *lc = &cpi->layer_context[i]; - int bits_off_for_this_layer = (int)(lc->target_bandwidth / lc->framerate - - cpi->projected_frame_size); + int bits_off_for_this_layer = (int)round( + lc->target_bandwidth / lc->framerate - cpi->projected_frame_size); lc->bits_off_target += bits_off_for_this_layer; @@ -4919,6 +4921,8 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen; last_duration = cpi->last_end_time_stamp_seen - cpi->last_time_stamp_seen; + // Cap this to avoid overflow of (this_duration - last_duration) * 10 + this_duration = VPXMIN(this_duration, INT64_MAX / 10); /* do a step update if the duration changes by 10% */ if (last_duration) { step = (int)(((this_duration - last_duration) * 10 / last_duration)); @@ -4988,7 +4992,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, if (cpi->oxcf.number_of_layers > 1) { int layer; - update_layer_contexts(cpi); + vp8_update_layer_contexts(cpi); /* Restore layer specific context & set frame rate */ if (cpi->temporal_layer_id >= 0) { @@ -4998,7 +5002,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, cpi->oxcf .layer_id[cpi->temporal_pattern_counter % cpi->oxcf.periodicity]; } - restore_layer_context(cpi, layer); + vp8_restore_layer_context(cpi, layer); vp8_new_framerate(cpi, cpi->layer_context[layer].framerate); } @@ -5129,7 +5133,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, } /* Save layer specific state */ - if (cpi->oxcf.number_of_layers > 1) save_layer_context(cpi); + if (cpi->oxcf.number_of_layers > 1) vp8_save_layer_context(cpi); vpx_usec_timer_mark(&cmptimer); cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer); @@ -5316,17 +5320,13 @@ int vp8_set_roimap(VP8_COMP *cpi, unsigned char *map, unsigned int rows, return -1; } - // Range check the delta Q values and convert the external Q range values - // to internal ones. - if ((abs(delta_q[0]) > range) || (abs(delta_q[1]) > range) || - (abs(delta_q[2]) > range) || (abs(delta_q[3]) > range)) { - return -1; - } - - // Range check the delta lf values - if ((abs(delta_lf[0]) > range) || (abs(delta_lf[1]) > range) || - (abs(delta_lf[2]) > range) || (abs(delta_lf[3]) > range)) { - return -1; + for (i = 0; i < MAX_MB_SEGMENTS; ++i) { + // Note abs() alone can't be used as the behavior of abs(INT_MIN) is + // undefined. + if (delta_q[i] > range || delta_q[i] < -range || delta_lf[i] > range || + delta_lf[i] < -range) { + return -1; + } } // Also disable segmentation if no deltas are specified. diff --git a/third_party/libvpx/vp8/encoder/onyx_int.h b/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h similarity index 97% rename from third_party/libvpx/vp8/encoder/onyx_int.h rename to third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h index b96f9b1dc5bc..7f8298e44a99 100644 --- a/third_party/libvpx/vp8/encoder/onyx_int.h +++ b/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h @@ -702,12 +702,22 @@ typedef struct VP8_COMP { int use_roi_static_threshold; int ext_refresh_frame_flags_pending; + + // Always update correction factor used for rate control after each frame for + // realtime encoding. + int rt_always_update_correction_factor; } VP8_COMP; void vp8_initialize_enc(void); void vp8_alloc_compressor_data(VP8_COMP *cpi); int vp8_reverse_trans(int x); +void vp8_init_temporal_layer_context(VP8_COMP *cpi, VP8_CONFIG *oxcf, + const int layer, + double prev_layer_framerate); +void vp8_update_layer_contexts(VP8_COMP *cpi); +void vp8_save_layer_context(VP8_COMP *cpi); +void vp8_restore_layer_context(VP8_COMP *cpi, const int layer); void vp8_new_framerate(VP8_COMP *cpi, double framerate); void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm); diff --git a/third_party/libvpx/vp8/encoder/pickinter.c b/third_party/libvpx/source/libvpx/vp8/encoder/pickinter.c similarity index 100% rename from third_party/libvpx/vp8/encoder/pickinter.c rename to third_party/libvpx/source/libvpx/vp8/encoder/pickinter.c diff --git a/third_party/libvpx/vp8/encoder/pickinter.h b/third_party/libvpx/source/libvpx/vp8/encoder/pickinter.h similarity index 100% rename from third_party/libvpx/vp8/encoder/pickinter.h rename to third_party/libvpx/source/libvpx/vp8/encoder/pickinter.h diff --git a/third_party/libvpx/vp8/encoder/picklpf.c b/third_party/libvpx/source/libvpx/vp8/encoder/picklpf.c similarity index 100% rename from third_party/libvpx/vp8/encoder/picklpf.c rename to third_party/libvpx/source/libvpx/vp8/encoder/picklpf.c diff --git a/third_party/libvpx/vp8/encoder/picklpf.h b/third_party/libvpx/source/libvpx/vp8/encoder/picklpf.h similarity index 100% rename from third_party/libvpx/vp8/encoder/picklpf.h rename to third_party/libvpx/source/libvpx/vp8/encoder/picklpf.h diff --git a/third_party/libvpx/vp8/encoder/quantize.h b/third_party/libvpx/source/libvpx/vp8/encoder/quantize.h similarity index 100% rename from third_party/libvpx/vp8/encoder/quantize.h rename to third_party/libvpx/source/libvpx/vp8/encoder/quantize.h diff --git a/third_party/libvpx/vp8/encoder/ratectrl.c b/third_party/libvpx/source/libvpx/vp8/encoder/ratectrl.c similarity index 99% rename from third_party/libvpx/vp8/encoder/ratectrl.c rename to third_party/libvpx/source/libvpx/vp8/encoder/ratectrl.c index ba124c359e55..4b76cc642969 100644 --- a/third_party/libvpx/vp8/encoder/ratectrl.c +++ b/third_party/libvpx/source/libvpx/vp8/encoder/ratectrl.c @@ -327,7 +327,8 @@ static void calc_iframe_target_size(VP8_COMP *cpi) { int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */ /* Boost depends somewhat on frame rate: only used for 1 layer case. */ if (cpi->oxcf.number_of_layers == 1) { - kf_boost = VPXMAX(initial_boost, (int)(2 * cpi->output_framerate - 16)); + kf_boost = + VPXMAX(initial_boost, (int)round(2 * cpi->output_framerate - 16)); } else { /* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */ kf_boost = initial_boost; @@ -349,8 +350,12 @@ static void calc_iframe_target_size(VP8_COMP *cpi) { } if (cpi->oxcf.rc_max_intra_bitrate_pct) { - unsigned int max_rate = - cpi->per_frame_bandwidth * cpi->oxcf.rc_max_intra_bitrate_pct / 100; + unsigned int max_rate; + // This product may overflow unsigned int + uint64_t product = cpi->per_frame_bandwidth; + product *= cpi->oxcf.rc_max_intra_bitrate_pct; + product /= 100; + max_rate = (unsigned int)VPXMIN(INT_MAX, product); if (target > max_rate) target = max_rate; } diff --git a/third_party/libvpx/vp8/encoder/ratectrl.h b/third_party/libvpx/source/libvpx/vp8/encoder/ratectrl.h similarity index 100% rename from third_party/libvpx/vp8/encoder/ratectrl.h rename to third_party/libvpx/source/libvpx/vp8/encoder/ratectrl.h diff --git a/third_party/libvpx/vp8/encoder/rdopt.c b/third_party/libvpx/source/libvpx/vp8/encoder/rdopt.c similarity index 100% rename from third_party/libvpx/vp8/encoder/rdopt.c rename to third_party/libvpx/source/libvpx/vp8/encoder/rdopt.c diff --git a/third_party/libvpx/vp8/encoder/rdopt.h b/third_party/libvpx/source/libvpx/vp8/encoder/rdopt.h similarity index 100% rename from third_party/libvpx/vp8/encoder/rdopt.h rename to third_party/libvpx/source/libvpx/vp8/encoder/rdopt.h diff --git a/third_party/libvpx/vp8/encoder/segmentation.c b/third_party/libvpx/source/libvpx/vp8/encoder/segmentation.c similarity index 100% rename from third_party/libvpx/vp8/encoder/segmentation.c rename to third_party/libvpx/source/libvpx/vp8/encoder/segmentation.c diff --git a/third_party/libvpx/vp8/encoder/segmentation.h b/third_party/libvpx/source/libvpx/vp8/encoder/segmentation.h similarity index 100% rename from third_party/libvpx/vp8/encoder/segmentation.h rename to third_party/libvpx/source/libvpx/vp8/encoder/segmentation.h diff --git a/third_party/libvpx/vp8/encoder/temporal_filter.c b/third_party/libvpx/source/libvpx/vp8/encoder/temporal_filter.c similarity index 100% rename from third_party/libvpx/vp8/encoder/temporal_filter.c rename to third_party/libvpx/source/libvpx/vp8/encoder/temporal_filter.c diff --git a/third_party/libvpx/vp8/encoder/temporal_filter.h b/third_party/libvpx/source/libvpx/vp8/encoder/temporal_filter.h similarity index 100% rename from third_party/libvpx/vp8/encoder/temporal_filter.h rename to third_party/libvpx/source/libvpx/vp8/encoder/temporal_filter.h diff --git a/third_party/libvpx/vp8/encoder/tokenize.c b/third_party/libvpx/source/libvpx/vp8/encoder/tokenize.c similarity index 100% rename from third_party/libvpx/vp8/encoder/tokenize.c rename to third_party/libvpx/source/libvpx/vp8/encoder/tokenize.c diff --git a/third_party/libvpx/vp8/encoder/tokenize.h b/third_party/libvpx/source/libvpx/vp8/encoder/tokenize.h similarity index 100% rename from third_party/libvpx/vp8/encoder/tokenize.h rename to third_party/libvpx/source/libvpx/vp8/encoder/tokenize.h diff --git a/third_party/libvpx/vp8/encoder/treewriter.c b/third_party/libvpx/source/libvpx/vp8/encoder/treewriter.c similarity index 100% rename from third_party/libvpx/vp8/encoder/treewriter.c rename to third_party/libvpx/source/libvpx/vp8/encoder/treewriter.c diff --git a/third_party/libvpx/vp8/encoder/treewriter.h b/third_party/libvpx/source/libvpx/vp8/encoder/treewriter.h similarity index 100% rename from third_party/libvpx/vp8/encoder/treewriter.h rename to third_party/libvpx/source/libvpx/vp8/encoder/treewriter.h diff --git a/third_party/libvpx/vp8/encoder/vp8_quantize.c b/third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c similarity index 100% rename from third_party/libvpx/vp8/encoder/vp8_quantize.c rename to third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c diff --git a/third_party/libvpx/vp8/encoder/x86/block_error_sse2.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/block_error_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/block_error_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/block_error_sse2.asm diff --git a/third_party/libvpx/vp8/encoder/x86/copy_sse2.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/copy_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse2.asm diff --git a/third_party/libvpx/vp8/encoder/x86/copy_sse3.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse3.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/copy_sse3.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse3.asm diff --git a/third_party/libvpx/vp8/encoder/x86/dct_sse2.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/dct_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/dct_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/dct_sse2.asm diff --git a/third_party/libvpx/vp8/encoder/x86/denoising_sse2.c b/third_party/libvpx/source/libvpx/vp8/encoder/x86/denoising_sse2.c similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/denoising_sse2.c rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/denoising_sse2.c diff --git a/third_party/libvpx/vp8/encoder/x86/fwalsh_sse2.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/fwalsh_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/fwalsh_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/fwalsh_sse2.asm diff --git a/third_party/libvpx/vp8/encoder/x86/quantize_sse4.c b/third_party/libvpx/source/libvpx/vp8/encoder/x86/quantize_sse4.c similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/quantize_sse4.c rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/quantize_sse4.c diff --git a/third_party/libvpx/vp8/encoder/x86/temporal_filter_apply_sse2.asm b/third_party/libvpx/source/libvpx/vp8/encoder/x86/temporal_filter_apply_sse2.asm similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/temporal_filter_apply_sse2.asm rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/temporal_filter_apply_sse2.asm diff --git a/third_party/libvpx/vp8/encoder/x86/vp8_enc_stubs_sse2.c b/third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_enc_stubs_sse2.c similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/vp8_enc_stubs_sse2.c rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_enc_stubs_sse2.c diff --git a/third_party/libvpx/vp8/encoder/x86/vp8_quantize_sse2.c b/third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_quantize_sse2.c similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/vp8_quantize_sse2.c rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_quantize_sse2.c diff --git a/third_party/libvpx/vp8/encoder/x86/vp8_quantize_ssse3.c b/third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_quantize_ssse3.c similarity index 100% rename from third_party/libvpx/vp8/encoder/x86/vp8_quantize_ssse3.c rename to third_party/libvpx/source/libvpx/vp8/encoder/x86/vp8_quantize_ssse3.c diff --git a/third_party/libvpx/vp8/exports_dec b/third_party/libvpx/source/libvpx/vp8/exports_dec similarity index 100% rename from third_party/libvpx/vp8/exports_dec rename to third_party/libvpx/source/libvpx/vp8/exports_dec diff --git a/third_party/libvpx/vp8/exports_enc b/third_party/libvpx/source/libvpx/vp8/exports_enc similarity index 100% rename from third_party/libvpx/vp8/exports_enc rename to third_party/libvpx/source/libvpx/vp8/exports_enc diff --git a/third_party/libvpx/vp8/vp8_common.mk b/third_party/libvpx/source/libvpx/vp8/vp8_common.mk similarity index 100% rename from third_party/libvpx/vp8/vp8_common.mk rename to third_party/libvpx/source/libvpx/vp8/vp8_common.mk diff --git a/third_party/libvpx/vp8/vp8_cx_iface.c b/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c similarity index 94% rename from third_party/libvpx/vp8/vp8_cx_iface.c rename to third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c index 1160f51d64a8..893b7a5132e7 100644 --- a/third_party/libvpx/vp8/vp8_cx_iface.c +++ b/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c @@ -152,8 +152,8 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK_HI(cfg, g_lag_in_frames, 25); #endif RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_Q); - RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000); - RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000); + RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100); + RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100); RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO); @@ -257,6 +257,23 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, ERROR("g_threads cannot be bigger than number of token partitions"); #endif + // The range below shall be further tuned. + RANGE_CHECK(cfg, use_vizier_rc_params, 0, 1); + RANGE_CHECK(cfg, active_wq_factor.den, 1, 1000); + RANGE_CHECK(cfg, err_per_mb_factor.den, 1, 1000); + RANGE_CHECK(cfg, sr_default_decay_limit.den, 1, 1000); + RANGE_CHECK(cfg, sr_diff_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_err_per_mb_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_frame_min_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_frame_max_boost_subs_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_max_total_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, gf_max_total_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, gf_frame_max_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, zm_factor.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000); + return VPX_CODEC_OK; } @@ -378,6 +395,9 @@ static vpx_codec_err_t set_vp8e_config(VP8_CONFIG *oxcf, #endif oxcf->cpu_used = vp8_cfg.cpu_used; + if (cfg.g_pass == VPX_RC_FIRST_PASS) { + oxcf->cpu_used = VPXMAX(4, oxcf->cpu_used); + } oxcf->encode_breakout = vp8_cfg.static_thresh; oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref; oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity; @@ -585,6 +605,17 @@ static vpx_codec_err_t set_screen_content_mode(vpx_codec_alg_priv_t *ctx, return update_extracfg(ctx, &extra_cfg); } +static vpx_codec_err_t ctrl_set_rtc_external_ratectrl(vpx_codec_alg_priv_t *ctx, + va_list args) { + VP8_COMP *cpi = ctx->cpi; + const unsigned int data = CAST(VP8E_SET_GF_CBR_BOOST_PCT, args); + if (data) { + cpi->cyclic_refresh_mode_enabled = 0; + cpi->rt_always_update_correction_factor = 1; + } + return VPX_CODEC_OK; +} + static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg, void **mem_loc) { vpx_codec_err_t res = VPX_CODEC_OK; @@ -1223,6 +1254,7 @@ static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = { { VP8E_SET_MAX_INTRA_BITRATE_PCT, set_rc_max_intra_bitrate_pct }, { VP8E_SET_SCREEN_CONTENT_MODE, set_screen_content_mode }, { VP8E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct }, + { VP8E_SET_RTC_EXTERNAL_RATECTRL, ctrl_set_rtc_external_ratectrl }, { -1, NULL }, }; @@ -1256,7 +1288,7 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { VPX_VBR, /* rc_end_usage */ { NULL, 0 }, /* rc_twopass_stats_in */ { NULL, 0 }, /* rc_firstpass_mb_stats_in */ - 256, /* rc_target_bandwidth */ + 256, /* rc_target_bitrate */ 4, /* rc_min_quantizer */ 63, /* rc_max_quantizer */ 100, /* rc_undershoot_pct */ @@ -1278,14 +1310,30 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { VPX_SS_DEFAULT_LAYERS, /* ss_number_layers */ { 0 }, - { 0 }, /* ss_target_bitrate */ - 1, /* ts_number_layers */ - { 0 }, /* ts_target_bitrate */ - { 0 }, /* ts_rate_decimator */ - 0, /* ts_periodicity */ - { 0 }, /* ts_layer_id */ - { 0 }, /* layer_target_bitrate */ - 0 /* temporal_layering_mode */ + { 0 }, /* ss_target_bitrate */ + 1, /* ts_number_layers */ + { 0 }, /* ts_target_bitrate */ + { 0 }, /* ts_rate_decimator */ + 0, /* ts_periodicity */ + { 0 }, /* ts_layer_id */ + { 0 }, /* layer_target_bitrate */ + 0, /* temporal_layering_mode */ + 0, /* use_vizier_rc_params */ + { 1, 1 }, /* active_wq_factor */ + { 1, 1 }, /* err_per_mb_factor */ + { 1, 1 }, /* sr_default_decay_limit */ + { 1, 1 }, /* sr_diff_factor */ + { 1, 1 }, /* kf_err_per_mb_factor */ + { 1, 1 }, /* kf_frame_min_boost_factor */ + { 1, 1 }, /* kf_frame_max_boost_first_factor */ + { 1, 1 }, /* kf_frame_max_boost_subs_factor */ + { 1, 1 }, /* kf_max_total_boost_factor */ + { 1, 1 }, /* gf_max_total_boost_factor */ + { 1, 1 }, /* gf_frame_max_boost_factor */ + { 1, 1 }, /* zm_factor */ + { 1, 1 }, /* rd_mult_inter_qp_fac */ + { 1, 1 }, /* rd_mult_arf_qp_fac */ + { 1, 1 }, /* rd_mult_key_qp_fac */ } }, }; diff --git a/third_party/libvpx/vp8/vp8_dx_iface.c b/third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c similarity index 100% rename from third_party/libvpx/vp8/vp8_dx_iface.c rename to third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c diff --git a/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.cc b/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.cc new file mode 100644 index 000000000000..2f23c5b1d9a7 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.cc @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2021 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include +#include "vp8/vp8_ratectrl_rtc.h" +#include "vp8/encoder/ratectrl.h" +#include "vpx_ports/system_state.h" + +namespace libvpx { +/* Quant MOD */ +static const int kQTrans[] = { + 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, + 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 64, 67, 70, 73, 76, 79, + 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124, 127, +}; + +static const unsigned char kf_high_motion_minq[QINDEX_RANGE] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, + 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, + 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 13, 13, 14, 14, 15, 15, 15, 15, 16, + 16, 16, 16, 17, 17, 18, 18, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, + 22, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30 +}; + +static const unsigned char inter_minq[QINDEX_RANGE] = { + 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 11, + 11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23, 24, + 24, 25, 26, 27, 27, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, + 39, 39, 40, 41, 42, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 50, 51, 52, 53, + 54, 55, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 65, 66, 67, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 +}; + +static int rescale(int val, int num, int denom) { + int64_t llnum = num; + int64_t llden = denom; + int64_t llval = val; + + return (int)(llval * llnum / llden); +} + +std::unique_ptr VP8RateControlRTC::Create( + const VP8RateControlRtcConfig &cfg) { + std::unique_ptr rc_api(new (std::nothrow) + VP8RateControlRTC()); + if (!rc_api) return nullptr; + rc_api->cpi_ = static_cast(vpx_memalign(32, sizeof(*cpi_))); + if (!rc_api->cpi_) return nullptr; + vp8_zero(*rc_api->cpi_); + + rc_api->InitRateControl(cfg); + + return rc_api; +} + +void VP8RateControlRTC::InitRateControl(const VP8RateControlRtcConfig &rc_cfg) { + VP8_COMMON *cm = &cpi_->common; + VP8_CONFIG *oxcf = &cpi_->oxcf; + oxcf->end_usage = USAGE_STREAM_FROM_SERVER; + cpi_->pass = 0; + cm->show_frame = 1; + oxcf->drop_frames_water_mark = 0; + cm->current_video_frame = 0; + cpi_->auto_gold = 1; + cpi_->key_frame_count = 1; + cpi_->rate_correction_factor = 1.0; + cpi_->key_frame_rate_correction_factor = 1.0; + cpi_->cyclic_refresh_mode_enabled = 0; + cpi_->auto_worst_q = 1; + cpi_->kf_overspend_bits = 0; + cpi_->kf_bitrate_adjustment = 0; + cpi_->gf_overspend_bits = 0; + cpi_->non_gf_bitrate_adjustment = 0; + UpdateRateControl(rc_cfg); + cpi_->buffer_level = oxcf->starting_buffer_level; + cpi_->bits_off_target = oxcf->starting_buffer_level; +} + +void VP8RateControlRTC::UpdateRateControl( + const VP8RateControlRtcConfig &rc_cfg) { + VP8_COMMON *cm = &cpi_->common; + VP8_CONFIG *oxcf = &cpi_->oxcf; + vpx_clear_system_state(); + cm->Width = rc_cfg.width; + cm->Height = rc_cfg.height; + oxcf->Width = rc_cfg.width; + oxcf->Height = rc_cfg.height; + oxcf->worst_allowed_q = kQTrans[rc_cfg.max_quantizer]; + oxcf->best_allowed_q = kQTrans[rc_cfg.min_quantizer]; + cpi_->worst_quality = oxcf->worst_allowed_q; + cpi_->best_quality = oxcf->best_allowed_q; + cpi_->output_framerate = rc_cfg.framerate; + oxcf->target_bandwidth = + static_cast(1000 * rc_cfg.target_bandwidth); + cpi_->ref_framerate = cpi_->output_framerate; + oxcf->fixed_q = -1; + oxcf->error_resilient_mode = 1; + oxcf->starting_buffer_level_in_ms = rc_cfg.buf_initial_sz; + oxcf->optimal_buffer_level_in_ms = rc_cfg.buf_optimal_sz; + oxcf->maximum_buffer_size_in_ms = rc_cfg.buf_sz; + oxcf->starting_buffer_level = rc_cfg.buf_initial_sz; + oxcf->optimal_buffer_level = rc_cfg.buf_optimal_sz; + oxcf->maximum_buffer_size = rc_cfg.buf_sz; + oxcf->number_of_layers = rc_cfg.ts_number_layers; + cpi_->buffered_mode = oxcf->optimal_buffer_level > 0; + oxcf->under_shoot_pct = rc_cfg.undershoot_pct; + oxcf->over_shoot_pct = rc_cfg.overshoot_pct; + cpi_->oxcf.rc_max_intra_bitrate_pct = rc_cfg.max_intra_bitrate_pct; + cpi_->framerate = rc_cfg.framerate; + for (int i = 0; i < KEY_FRAME_CONTEXT; ++i) { + cpi_->prior_key_frame_distance[i] = + static_cast(cpi_->output_framerate); + } + + if (oxcf->number_of_layers > 1) { + memcpy(oxcf->target_bitrate, rc_cfg.layer_target_bitrate, + sizeof(rc_cfg.layer_target_bitrate)); + memcpy(oxcf->rate_decimator, rc_cfg.ts_rate_decimator, + sizeof(rc_cfg.ts_rate_decimator)); + oxcf->periodicity = 2; + + double prev_layer_framerate = 0; + for (unsigned int i = 0; i < oxcf->number_of_layers; ++i) { + vp8_init_temporal_layer_context(cpi_, oxcf, i, prev_layer_framerate); + prev_layer_framerate = cpi_->output_framerate / oxcf->rate_decimator[i]; + } + } + + cpi_->total_actual_bits = 0; + cpi_->total_target_vs_actual = 0; + + cm->mb_rows = cm->Height >> 4; + cm->mb_cols = cm->Width >> 4; + cm->MBs = cm->mb_rows * cm->mb_cols; + cm->mode_info_stride = cm->mb_cols + 1; + + oxcf->starting_buffer_level = + rescale((int)oxcf->starting_buffer_level, oxcf->target_bandwidth, 1000); + /* Set or reset optimal and maximum buffer levels. */ + if (oxcf->optimal_buffer_level == 0) { + oxcf->optimal_buffer_level = oxcf->target_bandwidth / 8; + } else { + oxcf->optimal_buffer_level = + rescale((int)oxcf->optimal_buffer_level, oxcf->target_bandwidth, 1000); + } + if (oxcf->maximum_buffer_size == 0) { + oxcf->maximum_buffer_size = oxcf->target_bandwidth / 8; + } else { + oxcf->maximum_buffer_size = + rescale((int)oxcf->maximum_buffer_size, oxcf->target_bandwidth, 1000); + } + + if (cpi_->bits_off_target > oxcf->maximum_buffer_size) { + cpi_->bits_off_target = oxcf->maximum_buffer_size; + cpi_->buffer_level = cpi_->bits_off_target; + } + + vp8_new_framerate(cpi_, cpi_->framerate); + vpx_clear_system_state(); +} + +void VP8RateControlRTC::ComputeQP(const VP8FrameParamsQpRTC &frame_params) { + VP8_COMMON *const cm = &cpi_->common; + vpx_clear_system_state(); + if (cpi_->oxcf.number_of_layers > 1) { + cpi_->temporal_layer_id = frame_params.temporal_layer_id; + const int layer = frame_params.temporal_layer_id; + vp8_update_layer_contexts(cpi_); + /* Restore layer specific context & set frame rate */ + vp8_restore_layer_context(cpi_, layer); + vp8_new_framerate(cpi_, cpi_->layer_context[layer].framerate); + } + cm->frame_type = frame_params.frame_type; + cm->refresh_golden_frame = (cm->frame_type == KEY_FRAME) ? 1 : 0; + cm->refresh_alt_ref_frame = (cm->frame_type == KEY_FRAME) ? 1 : 0; + if (cm->frame_type == KEY_FRAME && cpi_->common.current_video_frame > 0) { + cpi_->common.frame_flags |= FRAMEFLAGS_KEY; + } + + vp8_pick_frame_size(cpi_); + + if (cpi_->buffer_level >= cpi_->oxcf.optimal_buffer_level && + cpi_->buffered_mode) { + /* Max adjustment is 1/4 */ + int Adjustment = cpi_->active_worst_quality / 4; + if (Adjustment) { + int buff_lvl_step; + if (cpi_->buffer_level < cpi_->oxcf.maximum_buffer_size) { + buff_lvl_step = (int)((cpi_->oxcf.maximum_buffer_size - + cpi_->oxcf.optimal_buffer_level) / + Adjustment); + if (buff_lvl_step) { + Adjustment = + (int)((cpi_->buffer_level - cpi_->oxcf.optimal_buffer_level) / + buff_lvl_step); + } else { + Adjustment = 0; + } + } + cpi_->active_worst_quality -= Adjustment; + if (cpi_->active_worst_quality < cpi_->active_best_quality) { + cpi_->active_worst_quality = cpi_->active_best_quality; + } + } + } + + if (cpi_->ni_frames > 150) { + int q = cpi_->active_worst_quality; + if (cm->frame_type == KEY_FRAME) { + cpi_->active_best_quality = kf_high_motion_minq[q]; + } else { + cpi_->active_best_quality = inter_minq[q]; + } + + if (cpi_->buffer_level >= cpi_->oxcf.maximum_buffer_size) { + cpi_->active_best_quality = cpi_->best_quality; + + } else if (cpi_->buffer_level > cpi_->oxcf.optimal_buffer_level) { + int Fraction = + (int)(((cpi_->buffer_level - cpi_->oxcf.optimal_buffer_level) * 128) / + (cpi_->oxcf.maximum_buffer_size - + cpi_->oxcf.optimal_buffer_level)); + int min_qadjustment = + ((cpi_->active_best_quality - cpi_->best_quality) * Fraction) / 128; + + cpi_->active_best_quality -= min_qadjustment; + } + } + + /* Clip the active best and worst quality values to limits */ + if (cpi_->active_worst_quality > cpi_->worst_quality) { + cpi_->active_worst_quality = cpi_->worst_quality; + } + if (cpi_->active_best_quality < cpi_->best_quality) { + cpi_->active_best_quality = cpi_->best_quality; + } + if (cpi_->active_worst_quality < cpi_->active_best_quality) { + cpi_->active_worst_quality = cpi_->active_best_quality; + } + + q_ = vp8_regulate_q(cpi_, cpi_->this_frame_target); + vp8_set_quantizer(cpi_, q_); + vpx_clear_system_state(); +} + +int VP8RateControlRTC::GetQP() const { return q_; } + +void VP8RateControlRTC::PostEncodeUpdate(uint64_t encoded_frame_size) { + VP8_COMMON *const cm = &cpi_->common; + vpx_clear_system_state(); + cpi_->total_byte_count += encoded_frame_size; + cpi_->projected_frame_size = static_cast(encoded_frame_size << 3); + if (cpi_->oxcf.number_of_layers > 1) { + for (unsigned int i = cpi_->current_layer + 1; + i < cpi_->oxcf.number_of_layers; ++i) { + cpi_->layer_context[i].total_byte_count += encoded_frame_size; + } + } + + vp8_update_rate_correction_factors(cpi_, 2); + + cpi_->last_q[cm->frame_type] = cm->base_qindex; + + if (cm->frame_type == KEY_FRAME) { + vp8_adjust_key_frame_context(cpi_); + } + + /* Keep a record of ambient average Q. */ + if (cm->frame_type != KEY_FRAME) { + cpi_->avg_frame_qindex = + (2 + 3 * cpi_->avg_frame_qindex + cm->base_qindex) >> 2; + } + /* Keep a record from which we can calculate the average Q excluding + * key frames. + */ + if (cm->frame_type != KEY_FRAME) { + cpi_->ni_frames++; + /* Damp value for first few frames */ + if (cpi_->ni_frames > 150) { + cpi_->ni_tot_qi += q_; + cpi_->ni_av_qi = (cpi_->ni_tot_qi / cpi_->ni_frames); + } else { + cpi_->ni_tot_qi += q_; + cpi_->ni_av_qi = + ((cpi_->ni_tot_qi / cpi_->ni_frames) + cpi_->worst_quality + 1) / 2; + } + + /* If the average Q is higher than what was used in the last + * frame (after going through the recode loop to keep the frame + * size within range) then use the last frame value - 1. The -1 + * is designed to stop Q and hence the data rate, from + * progressively falling away during difficult sections, but at + * the same time reduce the number of itterations around the + * recode loop. + */ + if (q_ > cpi_->ni_av_qi) cpi_->ni_av_qi = q_ - 1; + } + + cpi_->bits_off_target += + cpi_->av_per_frame_bandwidth - cpi_->projected_frame_size; + if (cpi_->bits_off_target > cpi_->oxcf.maximum_buffer_size) { + cpi_->bits_off_target = cpi_->oxcf.maximum_buffer_size; + } + + cpi_->total_actual_bits += cpi_->projected_frame_size; + cpi_->buffer_level = cpi_->bits_off_target; + + /* Propagate values to higher temporal layers */ + if (cpi_->oxcf.number_of_layers > 1) { + for (unsigned int i = cpi_->current_layer + 1; + i < cpi_->oxcf.number_of_layers; ++i) { + LAYER_CONTEXT *lc = &cpi_->layer_context[i]; + int bits_off_for_this_layer = (int)round( + lc->target_bandwidth / lc->framerate - cpi_->projected_frame_size); + + lc->bits_off_target += bits_off_for_this_layer; + + /* Clip buffer level to maximum buffer size for the layer */ + if (lc->bits_off_target > lc->maximum_buffer_size) { + lc->bits_off_target = lc->maximum_buffer_size; + } + + lc->total_actual_bits += cpi_->projected_frame_size; + lc->total_target_vs_actual += bits_off_for_this_layer; + lc->buffer_level = lc->bits_off_target; + } + } + + cpi_->common.current_video_frame++; + cpi_->frames_since_key++; + + if (cpi_->oxcf.number_of_layers > 1) vp8_save_layer_context(cpi_); + vpx_clear_system_state(); +} +} // namespace libvpx diff --git a/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.h b/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.h new file mode 100644 index 000000000000..def7dd8f9e10 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_VP8_RATECTRL_RTC_H_ +#define VPX_VP8_RATECTRL_RTC_H_ + +#include +#include + +#include "vp8/encoder/onyx_int.h" +#include "vp8/common/common.h" +#include "vpx/internal/vpx_ratectrl_rtc.h" + +namespace libvpx { +struct VP8RateControlRtcConfig : public VpxRateControlRtcConfig { + public: + VP8RateControlRtcConfig() { + vp8_zero(layer_target_bitrate); + vp8_zero(ts_rate_decimator); + } +}; + +struct VP8FrameParamsQpRTC { + FRAME_TYPE frame_type; + int temporal_layer_id; +}; + +class VP8RateControlRTC { + public: + static std::unique_ptr Create( + const VP8RateControlRtcConfig &cfg); + ~VP8RateControlRTC() { + if (cpi_) { + vpx_free(cpi_->gf_active_flags); + vpx_free(cpi_); + } + } + + void UpdateRateControl(const VP8RateControlRtcConfig &rc_cfg); + // GetQP() needs to be called after ComputeQP() to get the latest QP + int GetQP() const; + // int GetLoopfilterLevel() const; + void ComputeQP(const VP8FrameParamsQpRTC &frame_params); + // Feedback to rate control with the size of current encoded frame + void PostEncodeUpdate(uint64_t encoded_frame_size); + + private: + VP8RateControlRTC() {} + void InitRateControl(const VP8RateControlRtcConfig &cfg); + VP8_COMP *cpi_; + int q_; +}; + +} // namespace libvpx + +#endif // VPX_VP8_RATECTRL_RTC_H_ diff --git a/third_party/libvpx/vp8/vp8cx.mk b/third_party/libvpx/source/libvpx/vp8/vp8cx.mk similarity index 100% rename from third_party/libvpx/vp8/vp8cx.mk rename to third_party/libvpx/source/libvpx/vp8/vp8cx.mk diff --git a/third_party/libvpx/vp8/vp8dx.mk b/third_party/libvpx/source/libvpx/vp8/vp8dx.mk similarity index 100% rename from third_party/libvpx/vp8/vp8dx.mk rename to third_party/libvpx/source/libvpx/vp8/vp8dx.mk diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c diff --git a/third_party/libvpx/vp9/common/arm/neon/vp9_iht_neon.h b/third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht_neon.h similarity index 100% rename from third_party/libvpx/vp9/common/arm/neon/vp9_iht_neon.h rename to third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht_neon.h diff --git a/third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c b/third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c diff --git a/third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c b/third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c diff --git a/third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c b/third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c diff --git a/third_party/libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c b/third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c diff --git a/third_party/libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c b/third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c diff --git a/third_party/libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c b/third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c diff --git a/third_party/libvpx/vp9/common/mips/msa/vp9_mfqe_msa.c b/third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_mfqe_msa.c similarity index 100% rename from third_party/libvpx/vp9/common/mips/msa/vp9_mfqe_msa.c rename to third_party/libvpx/source/libvpx/vp9/common/mips/msa/vp9_mfqe_msa.c diff --git a/third_party/libvpx/vp9/common/ppc/vp9_idct_vsx.c b/third_party/libvpx/source/libvpx/vp9/common/ppc/vp9_idct_vsx.c similarity index 100% rename from third_party/libvpx/vp9/common/ppc/vp9_idct_vsx.c rename to third_party/libvpx/source/libvpx/vp9/common/ppc/vp9_idct_vsx.c diff --git a/third_party/libvpx/vp9/common/vp9_alloccommon.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_alloccommon.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c diff --git a/third_party/libvpx/vp9/common/vp9_alloccommon.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_alloccommon.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.h diff --git a/third_party/libvpx/vp9/common/vp9_blockd.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_blockd.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c diff --git a/third_party/libvpx/vp9/common/vp9_blockd.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_blockd.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.h diff --git a/third_party/libvpx/vp9/common/vp9_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_common.h diff --git a/third_party/libvpx/vp9/common/vp9_common_data.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_common_data.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c diff --git a/third_party/libvpx/vp9/common/vp9_common_data.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_common_data.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.h diff --git a/third_party/libvpx/vp9/common/vp9_debugmodes.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_debugmodes.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_debugmodes.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_debugmodes.c diff --git a/third_party/libvpx/vp9/common/vp9_entropy.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropy.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropy.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropy.c diff --git a/third_party/libvpx/vp9/common/vp9_entropy.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropy.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropy.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropy.h diff --git a/third_party/libvpx/vp9/common/vp9_entropymode.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropymode.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropymode.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropymode.c diff --git a/third_party/libvpx/vp9/common/vp9_entropymode.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropymode.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropymode.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropymode.h diff --git a/third_party/libvpx/vp9/common/vp9_entropymv.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropymv.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropymv.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropymv.c diff --git a/third_party/libvpx/vp9/common/vp9_entropymv.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_entropymv.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_entropymv.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_entropymv.h diff --git a/third_party/libvpx/vp9/common/vp9_enums.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_enums.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_enums.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_enums.h diff --git a/third_party/libvpx/vp9/common/vp9_filter.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_filter.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_filter.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_filter.c diff --git a/third_party/libvpx/vp9/common/vp9_filter.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_filter.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_filter.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_filter.h diff --git a/third_party/libvpx/vp9/common/vp9_frame_buffers.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_frame_buffers.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_frame_buffers.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_frame_buffers.c diff --git a/third_party/libvpx/vp9/common/vp9_frame_buffers.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_frame_buffers.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_frame_buffers.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_frame_buffers.h diff --git a/third_party/libvpx/vp9/common/vp9_idct.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_idct.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_idct.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_idct.c diff --git a/third_party/libvpx/vp9/common/vp9_idct.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_idct.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_idct.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_idct.h diff --git a/third_party/libvpx/vp9/common/vp9_loopfilter.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_loopfilter.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_loopfilter.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_loopfilter.c diff --git a/third_party/libvpx/vp9/common/vp9_loopfilter.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_loopfilter.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_loopfilter.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_loopfilter.h diff --git a/third_party/libvpx/vp9/common/vp9_mfqe.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_mfqe.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_mfqe.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_mfqe.c diff --git a/third_party/libvpx/vp9/common/vp9_mfqe.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_mfqe.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_mfqe.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_mfqe.h diff --git a/third_party/libvpx/vp9/common/vp9_mv.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_mv.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_mv.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_mv.h diff --git a/third_party/libvpx/vp9/common/vp9_mvref_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_mvref_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_mvref_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_mvref_common.c diff --git a/third_party/libvpx/vp9/common/vp9_mvref_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_mvref_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_mvref_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_mvref_common.h diff --git a/third_party/libvpx/vp9/common/vp9_onyxc_int.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h similarity index 97% rename from third_party/libvpx/vp9/common/vp9_onyxc_int.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h index 6f9c6985f0d2..1cfc12f6fa11 100644 --- a/third_party/libvpx/vp9/common/vp9_onyxc_int.h +++ b/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h @@ -75,12 +75,10 @@ typedef struct { // TODO(angiebird): Set frame_index/frame_coding_index on the decoder side // properly. - int frame_index; // Display order in the video, it's equivalent to the - // show_idx defined in EncodeFrameInfo. -#if CONFIG_RATE_CTRL + int frame_index; // Display order in the video, it's equivalent to the + // show_idx defined in EncodeFrameInfo. int frame_coding_index; // The coding order (starting from zero) of this // frame. -#endif // CONFIG_RATE_CTRL vpx_codec_frame_buffer_t raw_frame_buffer; YV12_BUFFER_CONFIG buf; } RefCntBuffer; @@ -240,13 +238,11 @@ typedef struct VP9Common { // TODO(angiebird): current_video_frame/current_frame_coding_index into a // structure unsigned int current_video_frame; -#if CONFIG_RATE_CTRL // Each show or no show frame is assigned with a coding index based on its // coding order (starting from zero). // Current frame's coding index. int current_frame_coding_index; -#endif BITSTREAM_PROFILE profile; // VPX_BITS_8 in profile 0 or 1, VPX_BITS_10 or VPX_BITS_12 in profile 2 or 3. @@ -276,9 +272,7 @@ typedef struct VP9Common { static INLINE void init_frame_indexes(VP9_COMMON *cm) { cm->current_video_frame = 0; -#if CONFIG_RATE_CTRL cm->current_frame_coding_index = 0; -#endif // CONFIG_RATE_CTRL } static INLINE void update_frame_indexes(VP9_COMMON *cm, int show_frame) { @@ -287,9 +281,7 @@ static INLINE void update_frame_indexes(VP9_COMMON *cm, int show_frame) { // update not a real frame ++cm->current_video_frame; } -#if CONFIG_RATE_CTRL ++cm->current_frame_coding_index; -#endif // CONFIG_RATE_CTRL } typedef struct { diff --git a/third_party/libvpx/vp9/common/vp9_postproc.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_postproc.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c diff --git a/third_party/libvpx/vp9/common/vp9_postproc.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_postproc.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h diff --git a/third_party/libvpx/vp9/common/vp9_ppflags.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_ppflags.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_ppflags.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_ppflags.h diff --git a/third_party/libvpx/vp9/common/vp9_pred_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_pred_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_pred_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_pred_common.c diff --git a/third_party/libvpx/vp9/common/vp9_pred_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_pred_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_pred_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_pred_common.h diff --git a/third_party/libvpx/vp9/common/vp9_quant_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_quant_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_quant_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_quant_common.c diff --git a/third_party/libvpx/vp9/common/vp9_quant_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_quant_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_quant_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_quant_common.h diff --git a/third_party/libvpx/vp9/common/vp9_reconinter.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_reconinter.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_reconinter.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_reconinter.c diff --git a/third_party/libvpx/vp9/common/vp9_reconinter.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_reconinter.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_reconinter.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_reconinter.h diff --git a/third_party/libvpx/vp9/common/vp9_reconintra.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_reconintra.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_reconintra.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_reconintra.c diff --git a/third_party/libvpx/vp9/common/vp9_reconintra.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_reconintra.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_reconintra.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_reconintra.h diff --git a/third_party/libvpx/vp9/common/vp9_rtcd.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_rtcd.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_rtcd.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_rtcd.c diff --git a/third_party/libvpx/vp9/common/vp9_rtcd_defs.pl b/third_party/libvpx/source/libvpx/vp9/common/vp9_rtcd_defs.pl similarity index 100% rename from third_party/libvpx/vp9/common/vp9_rtcd_defs.pl rename to third_party/libvpx/source/libvpx/vp9/common/vp9_rtcd_defs.pl diff --git a/third_party/libvpx/vp9/common/vp9_scale.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_scale.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_scale.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_scale.c diff --git a/third_party/libvpx/vp9/common/vp9_scale.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_scale.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_scale.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_scale.h diff --git a/third_party/libvpx/vp9/common/vp9_scan.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_scan.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_scan.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_scan.c diff --git a/third_party/libvpx/vp9/common/vp9_scan.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_scan.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_scan.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_scan.h diff --git a/third_party/libvpx/vp9/common/vp9_seg_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_seg_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_seg_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_seg_common.c diff --git a/third_party/libvpx/vp9/common/vp9_seg_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_seg_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_seg_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_seg_common.h diff --git a/third_party/libvpx/vp9/common/vp9_thread_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_thread_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_thread_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_thread_common.c diff --git a/third_party/libvpx/vp9/common/vp9_thread_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_thread_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_thread_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_thread_common.h diff --git a/third_party/libvpx/vp9/common/vp9_tile_common.c b/third_party/libvpx/source/libvpx/vp9/common/vp9_tile_common.c similarity index 100% rename from third_party/libvpx/vp9/common/vp9_tile_common.c rename to third_party/libvpx/source/libvpx/vp9/common/vp9_tile_common.c diff --git a/third_party/libvpx/vp9/common/vp9_tile_common.h b/third_party/libvpx/source/libvpx/vp9/common/vp9_tile_common.h similarity index 100% rename from third_party/libvpx/vp9/common/vp9_tile_common.h rename to third_party/libvpx/source/libvpx/vp9/common/vp9_tile_common.h diff --git a/third_party/libvpx/vp9/common/x86/vp9_highbd_iht16x16_add_sse4.c b/third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht16x16_add_sse4.c similarity index 100% rename from third_party/libvpx/vp9/common/x86/vp9_highbd_iht16x16_add_sse4.c rename to third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht16x16_add_sse4.c diff --git a/third_party/libvpx/vp9/common/x86/vp9_highbd_iht4x4_add_sse4.c b/third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht4x4_add_sse4.c similarity index 100% rename from third_party/libvpx/vp9/common/x86/vp9_highbd_iht4x4_add_sse4.c rename to third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht4x4_add_sse4.c diff --git a/third_party/libvpx/vp9/common/x86/vp9_highbd_iht8x8_add_sse4.c b/third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht8x8_add_sse4.c similarity index 100% rename from third_party/libvpx/vp9/common/x86/vp9_highbd_iht8x8_add_sse4.c rename to third_party/libvpx/source/libvpx/vp9/common/x86/vp9_highbd_iht8x8_add_sse4.c diff --git a/third_party/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c b/third_party/libvpx/source/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c diff --git a/third_party/libvpx/vp9/common/x86/vp9_mfqe_sse2.asm b/third_party/libvpx/source/libvpx/vp9/common/x86/vp9_mfqe_sse2.asm similarity index 100% rename from third_party/libvpx/vp9/common/x86/vp9_mfqe_sse2.asm rename to third_party/libvpx/source/libvpx/vp9/common/x86/vp9_mfqe_sse2.asm diff --git a/third_party/libvpx/vp9/decoder/vp9_decodeframe.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodeframe.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decodeframe.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodeframe.c diff --git a/third_party/libvpx/vp9/decoder/vp9_decodeframe.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodeframe.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decodeframe.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodeframe.h diff --git a/third_party/libvpx/vp9/decoder/vp9_decodemv.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodemv.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decodemv.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodemv.c diff --git a/third_party/libvpx/vp9/decoder/vp9_decodemv.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodemv.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decodemv.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodemv.h diff --git a/third_party/libvpx/vp9/decoder/vp9_decoder.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decoder.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decoder.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decoder.c diff --git a/third_party/libvpx/vp9/decoder/vp9_decoder.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_decoder.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_decoder.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_decoder.h diff --git a/third_party/libvpx/vp9/decoder/vp9_detokenize.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_detokenize.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c diff --git a/third_party/libvpx/vp9/decoder/vp9_detokenize.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_detokenize.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.h diff --git a/third_party/libvpx/vp9/decoder/vp9_dsubexp.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_dsubexp.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c diff --git a/third_party/libvpx/vp9/decoder/vp9_dsubexp.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_dsubexp.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h diff --git a/third_party/libvpx/vp9/decoder/vp9_job_queue.c b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_job_queue.c rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c diff --git a/third_party/libvpx/vp9/decoder/vp9_job_queue.h b/third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h similarity index 100% rename from third_party/libvpx/vp9/decoder/vp9_job_queue.h rename to third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h diff --git a/third_party/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c b/third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c similarity index 99% rename from third_party/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c rename to third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c index 4152e7bb5d5d..53e8c7e49850 100644 --- a/third_party/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c @@ -21,6 +21,9 @@ // Compute the sum of all pixel differences of this MB. static INLINE int horizontal_add_s8x16(const int8x16_t v_sum_diff_total) { +#if defined(__aarch64__) + return vaddlvq_s8(v_sum_diff_total); +#else const int16x8_t fe_dc_ba_98_76_54_32_10 = vpaddlq_s8(v_sum_diff_total); const int32x4_t fedc_ba98_7654_3210 = vpaddlq_s16(fe_dc_ba_98_76_54_32_10); const int64x2_t fedcba98_76543210 = vpaddlq_s32(fedc_ba98_7654_3210); @@ -28,6 +31,7 @@ static INLINE int horizontal_add_s8x16(const int8x16_t v_sum_diff_total) { vget_low_s64(fedcba98_76543210)); const int sum_diff = vget_lane_s32(vreinterpret_s32_s64(x), 0); return sum_diff; +#endif } // Denoise a 16x1 vector. diff --git a/third_party/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c b/third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c similarity index 100% rename from third_party/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c rename to third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c diff --git a/third_party/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c b/third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c similarity index 100% rename from third_party/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c rename to third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c diff --git a/third_party/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c b/third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c similarity index 100% rename from third_party/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c rename to third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c diff --git a/third_party/libvpx/vp9/encoder/mips/msa/vp9_error_msa.c b/third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_error_msa.c similarity index 100% rename from third_party/libvpx/vp9/encoder/mips/msa/vp9_error_msa.c rename to third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_error_msa.c diff --git a/third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c b/third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c similarity index 100% rename from third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c rename to third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c diff --git a/third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c b/third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c similarity index 100% rename from third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c rename to third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c diff --git a/third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c b/third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c similarity index 100% rename from third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c rename to third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c diff --git a/third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct_msa.h b/third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct_msa.h similarity index 100% rename from third_party/libvpx/vp9/encoder/mips/msa/vp9_fdct_msa.h rename to third_party/libvpx/source/libvpx/vp9/encoder/mips/msa/vp9_fdct_msa.h diff --git a/third_party/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c b/third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c similarity index 100% rename from third_party/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c rename to third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c diff --git a/third_party/libvpx/vp9/encoder/vp9_alt_ref_aq.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_alt_ref_aq.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c diff --git a/third_party/libvpx/vp9/encoder/vp9_alt_ref_aq.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_alt_ref_aq.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_360.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_360.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_360.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_360.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_complexity.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_complexity.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_complexity.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_complexity.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c similarity index 97% rename from third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c index 858a41654605..f06fe472683c 100644 --- a/third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c @@ -48,6 +48,7 @@ CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) { assert(MAXQ <= 255); memset(cr->last_coded_q_map, MAXQ, last_coded_q_map_size); cr->counter_encode_maxq_scene_change = 0; + cr->content_mode = 1; return cr; } @@ -326,7 +327,8 @@ void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) { else rc->baseline_gf_interval = 40; if (cpi->oxcf.rc_mode == VPX_VBR) rc->baseline_gf_interval = 20; - if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40) + if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40 && + cr->content_mode) rc->baseline_gf_interval = 10; } @@ -388,7 +390,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { ? vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex) : vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex); // More aggressive settings for noisy content. - if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium) { + if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium && + cr->content_mode) { consec_zero_mv_thresh = 60; qindex_thresh = VPXMAX(vp9_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST1, cm->base_qindex), @@ -409,7 +412,7 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { #if CONFIG_VP9_HIGHBITDEPTH if (cpi->common.use_highbitdepth) compute_content = 0; #endif - if (cpi->Last_Source == NULL || + if (cr->content_mode == 0 || cpi->Last_Source == NULL || cpi->Last_Source->y_width != cpi->Source->y_width || cpi->Last_Source->y_height != cpi->Source->y_height) compute_content = 0; @@ -430,7 +433,8 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) { // reset to 0 later depending on the coding mode. if (cr->map[bl_index2] == 0) { count_tot++; - if (cr->last_coded_q_map[bl_index2] > qindex_thresh || + if (cr->content_mode == 0 || + cr->last_coded_q_map[bl_index2] > qindex_thresh || cpi->consec_zero_mv[bl_index2] < consec_zero_mv_thresh_block) { sum_map++; count_sel++; @@ -489,7 +493,8 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { rc->avg_frame_qindex[INTER_FRAME] < qp_thresh || (cpi->use_svc && cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) || - (!cpi->use_svc && rc->avg_frame_low_motion < thresh_low_motion && + (!cpi->use_svc && cr->content_mode && + rc->avg_frame_low_motion < thresh_low_motion && rc->frames_since_key > 40) || (!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh && rc->frames_since_key > 20)) { @@ -511,7 +516,8 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { cr->rate_ratio_qdelta = 3.0; } else { cr->rate_ratio_qdelta = 2.0; - if (cpi->noise_estimate.enabled && cpi->noise_estimate.level >= kMedium) { + if (cr->content_mode && cpi->noise_estimate.enabled && + cpi->noise_estimate.level >= kMedium) { // Reduce the delta-qp if the estimated source noise is above threshold. cr->rate_ratio_qdelta = 1.7; cr->rate_boost_fac = 13; @@ -528,7 +534,7 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { cr->percent_refresh = (cr->skip_flat_static_blocks) ? 5 : 10; // Increase the amount of refresh on scene change that is encoded at max Q, // increase for a few cycles of the refresh period (~100 / percent_refresh). - if (cr->counter_encode_maxq_scene_change < 30) + if (cr->content_mode && cr->counter_encode_maxq_scene_change < 30) cr->percent_refresh = (cr->skip_flat_static_blocks) ? 10 : 15; cr->rate_ratio_qdelta = 2.0; cr->rate_boost_fac = 10; @@ -575,6 +581,12 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { (double)(cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) / num8x8bl; cr->weight_segment = weight_segment; + if (cr->content_mode == 0) { + cr->actual_num_seg1_blocks = + cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100; + cr->actual_num_seg2_blocks = 0; + cr->weight_segment = (double)(cr->actual_num_seg1_blocks) / num8x8bl; + } } // Setup cyclic background refresh: set delta q and segmentation map. diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h similarity index 99% rename from third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h index b6d7fdeae77a..c74cee4743a5 100644 --- a/third_party/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h @@ -70,6 +70,7 @@ struct CYCLIC_REFRESH { int apply_cyclic_refresh; int counter_encode_maxq_scene_change; int skip_flat_static_blocks; + int content_mode; }; struct VP9_COMP; diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_variance.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_variance.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c diff --git a/third_party/libvpx/vp9/encoder/vp9_aq_variance.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_aq_variance.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h diff --git a/third_party/libvpx/vp9/encoder/vp9_bitstream.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_bitstream.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c diff --git a/third_party/libvpx/vp9/encoder/vp9_bitstream.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_bitstream.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h diff --git a/third_party/libvpx/vp9/encoder/vp9_block.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h similarity index 97% rename from third_party/libvpx/vp9/encoder/vp9_block.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h index 37a4605ad8ca..20294b4b949e 100644 --- a/third_party/libvpx/vp9/encoder/vp9_block.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h @@ -157,6 +157,9 @@ struct macroblock { // skip forward transform and quantization uint8_t skip_txfm[MAX_MB_PLANE << 2]; #define SKIP_TXFM_NONE 0 +// TODO(chengchen): consider remove SKIP_TXFM_AC_DC from vp9 completely +// since it increases risks of bad perceptual quality. +// https://crbug.com/webm/1729 #define SKIP_TXFM_AC_DC 1 #define SKIP_TXFM_AC_ONLY 2 diff --git a/third_party/libvpx/vp9/encoder/vp9_blockiness.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_blockiness.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_blockiness.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_blockiness.c diff --git a/third_party/libvpx/vp9/encoder/vp9_blockiness.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_blockiness.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_blockiness.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_blockiness.h diff --git a/third_party/libvpx/vp9/encoder/vp9_context_tree.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_context_tree.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c diff --git a/third_party/libvpx/vp9/encoder/vp9_context_tree.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_context_tree.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.h diff --git a/third_party/libvpx/vp9/encoder/vp9_cost.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_cost.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_cost.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_cost.c diff --git a/third_party/libvpx/vp9/encoder/vp9_cost.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_cost.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_cost.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_cost.h diff --git a/third_party/libvpx/vp9/encoder/vp9_dct.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_dct.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_dct.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_dct.c diff --git a/third_party/libvpx/vp9/encoder/vp9_denoiser.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_denoiser.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_denoiser.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_denoiser.c diff --git a/third_party/libvpx/vp9/encoder/vp9_denoiser.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_denoiser.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_denoiser.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_denoiser.h diff --git a/third_party/libvpx/vp9/encoder/vp9_encodeframe.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c similarity index 96% rename from third_party/libvpx/vp9/encoder/vp9_encodeframe.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c index dcd6476581ef..131c4887f270 100644 --- a/third_party/libvpx/vp9/encoder/vp9_encodeframe.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c @@ -159,37 +159,6 @@ unsigned int vp9_high_get_sby_perpixel_variance(VP9_COMP *cpi, } #endif // CONFIG_VP9_HIGHBITDEPTH -#if !CONFIG_REALTIME_ONLY -static unsigned int get_sby_perpixel_diff_variance(VP9_COMP *cpi, - const struct buf_2d *ref, - int mi_row, int mi_col, - BLOCK_SIZE bs) { - unsigned int sse, var; - uint8_t *last_y; - const YV12_BUFFER_CONFIG *last = get_ref_frame_buffer(cpi, LAST_FRAME); - - assert(last != NULL); - last_y = - &last->y_buffer[mi_row * MI_SIZE * last->y_stride + mi_col * MI_SIZE]; - var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, last_y, last->y_stride, &sse); - return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); -} - -static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi, MACROBLOCK *x, - int mi_row, int mi_col) { - unsigned int var = get_sby_perpixel_diff_variance( - cpi, &x->plane[0].src, mi_row, mi_col, BLOCK_64X64); - if (var < 8) - return BLOCK_64X64; - else if (var < 128) - return BLOCK_32X32; - else if (var < 2048) - return BLOCK_16X16; - else - return BLOCK_8X8; -} -#endif // !CONFIG_REALTIME_ONLY - static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row, int mi_col, BLOCK_SIZE bsize, int segment_index) { VP9_COMMON *const cm = &cpi->common; @@ -815,8 +784,8 @@ static void fill_variance_8x8avg(const uint8_t *s, int sp, const uint8_t *d, // Check if most of the superblock is skin content, and if so, force split to // 32x32, and set x->sb_is_skin for use in mode selection. -static int skin_sb_split(VP9_COMP *cpi, MACROBLOCK *x, const int low_res, - int mi_row, int mi_col, int *force_split) { +static int skin_sb_split(VP9_COMP *cpi, const int low_res, int mi_row, + int mi_col, int *force_split) { VP9_COMMON *const cm = &cpi->common; #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) return 0; @@ -828,11 +797,6 @@ static int skin_sb_split(VP9_COMP *cpi, MACROBLOCK *x, const int low_res, mi_row + 8 < cm->mi_rows)) { int num_16x16_skin = 0; int num_16x16_nonskin = 0; - uint8_t *ysignal = x->plane[0].src.buf; - uint8_t *usignal = x->plane[1].src.buf; - uint8_t *vsignal = x->plane[2].src.buf; - int sp = x->plane[0].src.stride; - int spuv = x->plane[1].src.stride; const int block_index = mi_row * cm->mi_cols + mi_col; const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64]; const int bh = num_8x8_blocks_high_lookup[BLOCK_64X64]; @@ -851,13 +815,7 @@ static int skin_sb_split(VP9_COMP *cpi, MACROBLOCK *x, const int low_res, i = ymis; break; } - ysignal += 16; - usignal += 8; - vsignal += 8; } - ysignal += (sp << 4) - 64; - usignal += (spuv << 3) - 32; - vsignal += (spuv << 3) - 32; } if (num_16x16_skin > 12) { *force_split = 1; @@ -1534,8 +1492,7 @@ static int choose_partitioning(VP9_COMP *cpi, const TileInfo *const tile, vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_64X64); if (cpi->use_skin_detection) - x->sb_is_skin = - skin_sb_split(cpi, x, low_res, mi_row, mi_col, force_split); + x->sb_is_skin = skin_sb_split(cpi, low_res, mi_row, mi_col, force_split); d = xd->plane[0].dst.buf; dp = xd->plane[0].dst.stride; @@ -1842,7 +1799,8 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, PICK_MODE_CONTEXT *ctx, } // Else for cyclic refresh mode update the segment map, set the segment id // and then update the quantizer. - if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && + cpi->cyclic_refresh->content_mode) { vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row, mi_col, bsize, ctx->rate, ctx->dist, x->skip, p); } @@ -2539,7 +2497,8 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td, if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) { // Setting segmentation map for cyclic_refresh. - if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && + cpi->cyclic_refresh->content_mode) { vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize, ctx->rate, ctx->dist, x->skip, p); } else { @@ -3119,54 +3078,6 @@ static INLINE void load_pred_mv(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) { memcpy(x->pred_mv, ctx->pred_mv, sizeof(x->pred_mv)); } -#if CONFIG_FP_MB_STATS -const int num_16x16_blocks_wide_lookup[BLOCK_SIZES] = { 1, 1, 1, 1, 1, 1, 1, - 1, 2, 2, 2, 4, 4 }; -const int num_16x16_blocks_high_lookup[BLOCK_SIZES] = { 1, 1, 1, 1, 1, 1, 1, - 2, 1, 2, 4, 2, 4 }; -const int qindex_skip_threshold_lookup[BLOCK_SIZES] = { 0, 10, 10, 30, 40, - 40, 60, 80, 80, 90, - 100, 100, 120 }; -const int qindex_split_threshold_lookup[BLOCK_SIZES] = { 0, 3, 3, 7, 15, - 15, 30, 40, 40, 60, - 80, 80, 120 }; -const int complexity_16x16_blocks_threshold[BLOCK_SIZES] = { 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 4, 4, 6 }; - -typedef enum { - MV_ZERO = 0, - MV_LEFT = 1, - MV_UP = 2, - MV_RIGHT = 3, - MV_DOWN = 4, - MV_INVALID -} MOTION_DIRECTION; - -static INLINE MOTION_DIRECTION get_motion_direction_fp(uint8_t fp_byte) { - if (fp_byte & FPMB_MOTION_ZERO_MASK) { - return MV_ZERO; - } else if (fp_byte & FPMB_MOTION_LEFT_MASK) { - return MV_LEFT; - } else if (fp_byte & FPMB_MOTION_RIGHT_MASK) { - return MV_RIGHT; - } else if (fp_byte & FPMB_MOTION_UP_MASK) { - return MV_UP; - } else { - return MV_DOWN; - } -} - -static INLINE int get_motion_inconsistency(MOTION_DIRECTION this_mv, - MOTION_DIRECTION that_mv) { - if (this_mv == that_mv) { - return 0; - } else { - return abs(this_mv - that_mv) == 2 ? 2 : 1; - } -} -#endif - // Calculate prediction based on the given input features and neural net config. // Assume there are no more than NN_MAX_NODES_PER_LAYER nodes in each hidden // layer. @@ -4064,11 +3975,6 @@ static int rd_pick_partition(VP9_COMP *cpi, ThreadData *td, BLOCK_SIZE min_size = x->min_partition_size; BLOCK_SIZE max_size = x->max_partition_size; -#if CONFIG_FP_MB_STATS - unsigned int src_diff_var = UINT_MAX; - int none_complexity = 0; -#endif - int partition_none_allowed = !force_horz_split && !force_vert_split; int partition_horz_allowed = !force_vert_split && yss <= xss && bsize >= BLOCK_8X8; @@ -4155,65 +4061,6 @@ static int rd_pick_partition(VP9_COMP *cpi, ThreadData *td, save_context(x, mi_row, mi_col, a, l, sa, sl, bsize); -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize); - src_diff_var = get_sby_perpixel_diff_variance(cpi, &x->plane[0].src, mi_row, - mi_col, bsize); - } -#endif - -#if CONFIG_FP_MB_STATS - // Decide whether we shall split directly and skip searching NONE by using - // the first pass block statistics - if (cpi->use_fp_mb_stats && bsize >= BLOCK_32X32 && do_split && - partition_none_allowed && src_diff_var > 4 && - cm->base_qindex < qindex_split_threshold_lookup[bsize]) { - int mb_row = mi_row >> 1; - int mb_col = mi_col >> 1; - int mb_row_end = - VPXMIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows); - int mb_col_end = - VPXMIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols); - int r, c; - - // compute a complexity measure, basically measure inconsistency of motion - // vectors obtained from the first pass in the current block - for (r = mb_row; r < mb_row_end; r++) { - for (c = mb_col; c < mb_col_end; c++) { - const int mb_index = r * cm->mb_cols + c; - - MOTION_DIRECTION this_mv; - MOTION_DIRECTION right_mv; - MOTION_DIRECTION bottom_mv; - - this_mv = - get_motion_direction_fp(cpi->twopass.this_frame_mb_stats[mb_index]); - - // to its right - if (c != mb_col_end - 1) { - right_mv = get_motion_direction_fp( - cpi->twopass.this_frame_mb_stats[mb_index + 1]); - none_complexity += get_motion_inconsistency(this_mv, right_mv); - } - - // to its bottom - if (r != mb_row_end - 1) { - bottom_mv = get_motion_direction_fp( - cpi->twopass.this_frame_mb_stats[mb_index + cm->mb_cols]); - none_complexity += get_motion_inconsistency(this_mv, bottom_mv); - } - - // do not count its left and top neighbors to avoid double counting - } - } - - if (none_complexity > complexity_16x16_blocks_threshold[bsize]) { - partition_none_allowed = 0; - } - } -#endif - pc_tree->partitioning = PARTITION_NONE; if (cpi->sf.rd_ml_partition.var_pruning && !frame_is_intra_only(cm)) { @@ -4291,53 +4138,6 @@ static int rd_pick_partition(VP9_COMP *cpi, ThreadData *td, } } } - -#if CONFIG_FP_MB_STATS - // Check if every 16x16 first pass block statistics has zero - // motion and the corresponding first pass residue is small enough. - // If that is the case, check the difference variance between the - // current frame and the last frame. If the variance is small enough, - // stop further splitting in RD optimization - if (cpi->use_fp_mb_stats && do_split != 0 && - cm->base_qindex > qindex_skip_threshold_lookup[bsize]) { - int mb_row = mi_row >> 1; - int mb_col = mi_col >> 1; - int mb_row_end = - VPXMIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows); - int mb_col_end = - VPXMIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols); - int r, c; - - int skip = 1; - for (r = mb_row; r < mb_row_end; r++) { - for (c = mb_col; c < mb_col_end; c++) { - const int mb_index = r * cm->mb_cols + c; - if (!(cpi->twopass.this_frame_mb_stats[mb_index] & - FPMB_MOTION_ZERO_MASK) || - !(cpi->twopass.this_frame_mb_stats[mb_index] & - FPMB_ERROR_SMALL_MASK)) { - skip = 0; - break; - } - } - if (skip == 0) { - break; - } - } - - if (skip) { - if (src_diff_var == UINT_MAX) { - set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize); - src_diff_var = get_sby_perpixel_diff_variance( - cpi, &x->plane[0].src, mi_row, mi_col, bsize); - } - if (src_diff_var < 8) { - do_split = 0; - do_rect = 0; - } - } - } -#endif } } restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize); @@ -4603,15 +4403,18 @@ static int rd_pick_partition(VP9_COMP *cpi, ThreadData *td, encode_sb(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, bsize, pc_tree); #if CONFIG_RATE_CTRL - // Store partition, motion vector of the superblock. - if (output_enabled) { - const int num_unit_rows = get_num_unit_4x4(cpi->frame_info.frame_height); - const int num_unit_cols = get_num_unit_4x4(cpi->frame_info.frame_width); - store_superblock_info(pc_tree, cm->mi_grid_visible, cm->mi_stride, - num_4x4_blocks_wide_lookup[BLOCK_64X64], - num_unit_rows, num_unit_cols, mi_row << 1, - mi_col << 1, cpi->partition_info, - cpi->motion_vector_info); + if (oxcf->use_simple_encode_api) { + // Store partition, motion vector of the superblock. + if (output_enabled) { + const int num_unit_rows = + get_num_unit_4x4(cpi->frame_info.frame_height); + const int num_unit_cols = get_num_unit_4x4(cpi->frame_info.frame_width); + store_superblock_info(pc_tree, cm->mi_grid_visible, cm->mi_stride, + num_4x4_blocks_wide_lookup[BLOCK_64X64], + num_unit_rows, num_unit_cols, mi_row << 1, + mi_col << 1, cpi->partition_info, + cpi->motion_vector_info); + } } #endif // CONFIG_RATE_CTRL } @@ -4700,13 +4503,6 @@ static void encode_rd_sb_row(VP9_COMP *cpi, ThreadData *td, set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rate, &dummy_dist, 1, td->pc_root); - } else if (cpi->partition_search_skippable_frame) { - BLOCK_SIZE bsize; - set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); - bsize = get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col); - set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); - rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, BLOCK_64X64, - &dummy_rate, &dummy_dist, 1, td->pc_root); } else if (sf->partition_search_type == VAR_BASED_PARTITION && cm->frame_type != KEY_FRAME) { choose_partitioning(cpi, tile_info, x, mi_row, mi_col); @@ -5981,9 +5777,14 @@ void vp9_init_tile_data(VP9_COMP *cpi) { for (i = 0; i < BLOCK_SIZES; ++i) { for (j = 0; j < MAX_MODES; ++j) { tile_data->thresh_freq_fact[i][j] = RD_THRESH_INIT_FACT; -#if CONFIG_CONSISTENT_RECODE || CONFIG_RATE_CTRL +#if CONFIG_RATE_CTRL + if (cpi->oxcf.use_simple_encode_api) { + tile_data->thresh_freq_fact_prev[i][j] = RD_THRESH_INIT_FACT; + } +#endif // CONFIG_RATE_CTRL +#if CONFIG_CONSISTENT_RECODE tile_data->thresh_freq_fact_prev[i][j] = RD_THRESH_INIT_FACT; -#endif // CONFIG_CONSISTENT_RECODE || CONFIG_RATE_CTRL +#endif // CONFIG_CONSISTENT_RECODE tile_data->mode_map[i][j] = j; } } @@ -6072,20 +5873,6 @@ static void encode_tiles(VP9_COMP *cpi) { vp9_encode_tile(cpi, &cpi->td, tile_row, tile_col); } -#if CONFIG_FP_MB_STATS -static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats, - VP9_COMMON *cm, uint8_t **this_frame_mb_stats) { - uint8_t *mb_stats_in = firstpass_mb_stats->mb_stats_start + - cm->current_video_frame * cm->MBs * sizeof(uint8_t); - - if (mb_stats_in > firstpass_mb_stats->mb_stats_end) return EOF; - - *this_frame_mb_stats = mb_stats_in; - - return 1; -} -#endif - static int compare_kmeans_data(const void *a, const void *b) { if (((const KMEANS_DATA *)a)->value > ((const KMEANS_DATA *)b)->value) { return 1; @@ -6292,13 +6079,6 @@ static void encode_frame_internal(VP9_COMP *cpi) { struct vpx_usec_timer emr_timer; vpx_usec_timer_start(&emr_timer); -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - input_fpmb_stats(&cpi->twopass.firstpass_mb_stats, cm, - &cpi->twopass.this_frame_mb_stats); - } -#endif - if (!cpi->row_mt) { cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read_dummy; cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write_dummy; @@ -6406,7 +6186,12 @@ static void restore_encode_params(VP9_COMP *cpi) { void vp9_encode_frame(VP9_COMP *cpi) { VP9_COMMON *const cm = &cpi->common; -#if CONFIG_CONSISTENT_RECODE || CONFIG_RATE_CTRL +#if CONFIG_RATE_CTRL + if (cpi->oxcf.use_simple_encode_api) { + restore_encode_params(cpi); + } +#endif // CONFIG_RATE_CTRL +#if CONFIG_CONSISTENT_RECODE restore_encode_params(cpi); #endif @@ -6703,7 +6488,8 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, TOKENEXTRA **t, ++td->counts->tx.tx_totals[mi->tx_size]; ++td->counts->tx.tx_totals[get_uv_tx_size(mi, &xd->plane[1])]; - if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && + cpi->cyclic_refresh->content_mode) vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize); if (cpi->oxcf.pass == 0 && cpi->svc.temporal_layer_id == 0 && (!cpi->use_svc || diff --git a/third_party/libvpx/vp9/encoder/vp9_encodeframe.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_encodeframe.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.h diff --git a/third_party/libvpx/vp9/encoder/vp9_encodemb.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemb.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_encodemb.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemb.c diff --git a/third_party/libvpx/vp9/encoder/vp9_encodemb.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemb.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_encodemb.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemb.h diff --git a/third_party/libvpx/vp9/encoder/vp9_encodemv.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemv.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_encodemv.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemv.c diff --git a/third_party/libvpx/vp9/encoder/vp9_encodemv.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemv.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_encodemv.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodemv.h diff --git a/third_party/libvpx/vp9/encoder/vp9_encoder.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c similarity index 96% rename from third_party/libvpx/vp9/encoder/vp9_encoder.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c index 048559061510..7e80835f6c49 100644 --- a/third_party/libvpx/vp9/encoder/vp9_encoder.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c @@ -654,10 +654,15 @@ static void init_level_info(Vp9LevelInfo *level_info) { } static int check_seg_range(int seg_data[8], int range) { - return !(abs(seg_data[0]) > range || abs(seg_data[1]) > range || - abs(seg_data[2]) > range || abs(seg_data[3]) > range || - abs(seg_data[4]) > range || abs(seg_data[5]) > range || - abs(seg_data[6]) > range || abs(seg_data[7]) > range); + int i; + for (i = 0; i < 8; ++i) { + // Note abs() alone can't be used as the behavior of abs(INT_MIN) is + // undefined. + if (seg_data[i] > range || seg_data[i] < -range) { + return 0; + } + } + return 1; } VP9_LEVEL vp9_get_level(const Vp9LevelSpec *const level_spec) { @@ -1022,9 +1027,12 @@ static void dealloc_compressor_data(VP9_COMP *cpi) { cpi->mi_ssim_rdmult_scaling_factors = NULL; #if CONFIG_RATE_CTRL - free_partition_info(cpi); - free_motion_vector_info(cpi); - free_fp_motion_vector_info(cpi); + if (cpi->oxcf.use_simple_encode_api) { + free_partition_info(cpi); + free_motion_vector_info(cpi); + free_fp_motion_vector_info(cpi); + free_tpl_stats_info(cpi); + } #endif vp9_free_ref_frame_buffers(cm->buffer_pool); @@ -2301,6 +2309,7 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, cm, cm->frame_contexts, (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, sizeof(*cm->frame_contexts))); + cpi->compute_frame_low_motion_onepass = 1; cpi->use_svc = 0; cpi->resize_state = ORIG; cpi->external_resize = 0; @@ -2316,9 +2325,9 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, cpi->frame_info = vp9_get_frame_info(oxcf); vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); + vp9_init_rd_parameters(cpi); init_frame_indexes(cm); - cpi->partition_search_skippable_frame = 0; cpi->tile_data = NULL; realloc_segmentation_maps(cpi); @@ -2359,17 +2368,6 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, vpx_calloc(cm->MBs * sizeof(*cpi->mbgraph_stats[i].mb_stats), 1)); } -#if CONFIG_FP_MB_STATS - cpi->use_fp_mb_stats = 0; - if (cpi->use_fp_mb_stats) { - // a place holder used to store the first pass mb stats in the first pass - CHECK_MEM_ERROR(cm, cpi->twopass.frame_mb_stats_buf, - vpx_calloc(cm->MBs * sizeof(uint8_t), 1)); - } else { - cpi->twopass.frame_mb_stats_buf = NULL; - } -#endif - cpi->refresh_alt_ref_frame = 0; cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; @@ -2463,6 +2461,13 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED; + { + vpx_codec_err_t codec_status = vp9_extrc_init(&cpi->ext_ratectrl); + if (codec_status != VPX_CODEC_OK) { + vpx_internal_error(&cm->error, codec_status, "vp9_extrc_init() failed"); + } + } + #if !CONFIG_REALTIME_ONLY if (oxcf->pass == 1) { vp9_init_first_pass(cpi); @@ -2515,18 +2520,6 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, vp9_init_second_pass_spatial_svc(cpi); } else { int num_frames; -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - const size_t psz = cpi->common.MBs * sizeof(uint8_t); - const int ps = (int)(oxcf->firstpass_mb_stats_in.sz / psz); - - cpi->twopass.firstpass_mb_stats.mb_stats_start = - oxcf->firstpass_mb_stats_in.buf; - cpi->twopass.firstpass_mb_stats.mb_stats_end = - cpi->twopass.firstpass_mb_stats.mb_stats_start + - (ps - 1) * cpi->common.MBs * sizeof(uint8_t); - } -#endif cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf; cpi->twopass.stats_in = cpi->twopass.stats_in_start; @@ -2660,9 +2653,12 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, #if CONFIG_RATE_CTRL encode_command_init(&cpi->encode_command); - partition_info_init(cpi); - motion_vector_info_init(cpi); - fp_motion_vector_info_init(cpi); + if (oxcf->use_simple_encode_api) { + partition_info_init(cpi); + motion_vector_info_init(cpi); + fp_motion_vector_info_init(cpi); + tpl_stats_info_init(cpi); + } #endif return cpi; @@ -2827,12 +2823,7 @@ void vp9_remove_compressor(VP9_COMP *cpi) { vpx_free(cpi->mbgraph_stats[i].mb_stats); } -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - vpx_free(cpi->twopass.frame_mb_stats_buf); - cpi->twopass.frame_mb_stats_buf = NULL; - } -#endif + vp9_extrc_delete(&cpi->ext_ratectrl); vp9_remove_common(cm); vp9_free_ref_frame_buffers(cm->buffer_pool); @@ -3316,6 +3307,13 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { return; } + if (cpi->loopfilter_ctrl == NO_LOOPFILTER || + (!is_reference_frame && cpi->loopfilter_ctrl == LOOPFILTER_REFERENCE)) { + lf->filter_level = 0; + vpx_extend_frame_inner_borders(cm->frame_to_show); + return; + } + if (xd->lossless) { lf->filter_level = 0; lf->last_filt_level = 0; @@ -3685,6 +3683,10 @@ static void set_size_dependent_vars(VP9_COMP *cpi, int *q, int *bottom_index, cpi->rc.force_max_q = 0; } + if (cpi->use_svc) { + cpi->svc.base_qindex[cpi->svc.spatial_layer_id] = *q; + } + if (!frame_is_intra_only(cm)) { vp9_set_high_precision_mv(cpi, (*q) < HIGH_PRECISION_MV_QTHRESH); } @@ -4185,7 +4187,7 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size, // Update some stats from cyclic refresh, and check for golden frame update. if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled && - !frame_is_intra_only(cm)) + !frame_is_intra_only(cm) && cpi->cyclic_refresh->content_mode) vp9_cyclic_refresh_postencode(cpi); // Update the skip mb flag probabilities based on the distribution @@ -4195,6 +4197,27 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size, return 1; } +static int get_ref_frame_flags(const VP9_COMP *cpi) { + const int *const map = cpi->common.ref_frame_map; + const int gold_is_last = map[cpi->gld_fb_idx] == map[cpi->lst_fb_idx]; + const int alt_is_last = map[cpi->alt_fb_idx] == map[cpi->lst_fb_idx]; + const int gold_is_alt = map[cpi->gld_fb_idx] == map[cpi->alt_fb_idx]; + int flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; + + if (gold_is_last) flags &= ~VP9_GOLD_FLAG; + + if (cpi->rc.frames_till_gf_update_due == INT_MAX && + (cpi->svc.number_temporal_layers == 1 && + cpi->svc.number_spatial_layers == 1)) + flags &= ~VP9_GOLD_FLAG; + + if (alt_is_last) flags &= ~VP9_ALT_FLAG; + + if (gold_is_alt) flags &= ~VP9_ALT_FLAG; + + return flags; +} + #if !CONFIG_REALTIME_ONLY #define MAX_QSTEP_ADJ 4 static int get_qstep_adj(int rate_excess, int rate_limit) { @@ -4358,11 +4381,24 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest int frame_over_shoot_limit; int frame_under_shoot_limit; int q = 0, q_low = 0, q_high = 0; + int last_q_attempt = 0; int enable_acl; #ifdef AGGRESSIVE_VBR int qrange_adj = 1; #endif + // A flag which indicates whether we are recoding the current frame + // when the current frame size is larger than the max frame size in the + // external rate control model. + // This flag doesn't have any impact when external rate control is not used. + int ext_rc_recode = 0; + // Maximal frame size allowed by the external rate control. + // case: 0, we ignore the max frame size limit, and encode with the qindex + // passed in by the external rate control model. + // case: -1, we take VP9's decision for the max frame size. + int ext_rc_max_frame_size = 0; + const int orig_rc_max_frame_bandwidth = rc->max_frame_bandwidth; + #if CONFIG_RATE_CTRL const FRAME_UPDATE_TYPE update_type = cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index]; @@ -4417,11 +4453,6 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest loop_at_this_size = 0; } -#if CONFIG_RATE_CTRL - if (cpi->encode_command.use_external_target_frame_bits) { - q = rq_model_predict_q_index(rq_model, rq_history, rc->this_frame_target); - } -#endif // CONFIG_RATE_CTRL // Decide frame size bounds first time through. if (loop_count == 0) { vp9_rc_compute_frame_size_bounds(cpi, rc->this_frame_target, @@ -4464,10 +4495,37 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest #if CONFIG_RATE_CTRL // TODO(angiebird): This is a hack for making sure the encoder use the // external_quantize_index exactly. Avoid this kind of hack later. - if (cpi->encode_command.use_external_quantize_index) { - q = cpi->encode_command.external_quantize_index; + if (cpi->oxcf.use_simple_encode_api) { + if (cpi->encode_command.use_external_target_frame_bits) { + q = rq_model_predict_q_index(rq_model, rq_history, + rc->this_frame_target); + } + if (cpi->encode_command.use_external_quantize_index) { + q = cpi->encode_command.external_quantize_index; + } + } +#endif // CONFIG_RATE_CTRL + if (cpi->ext_ratectrl.ready && !ext_rc_recode) { + vpx_codec_err_t codec_status; + const GF_GROUP *gf_group = &cpi->twopass.gf_group; + vpx_rc_encodeframe_decision_t encode_frame_decision; + FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index]; + const int ref_frame_flags = get_ref_frame_flags(cpi); + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES]; + const RefCntBuffer *curr_frame_buf = + get_ref_cnt_buffer(cm, cm->new_fb_idx); + get_ref_frame_bufs(cpi, ref_frame_bufs); + codec_status = vp9_extrc_get_encodeframe_decision( + &cpi->ext_ratectrl, curr_frame_buf->frame_index, + cm->current_frame_coding_index, gf_group->index, update_type, + ref_frame_bufs, ref_frame_flags, &encode_frame_decision); + if (codec_status != VPX_CODEC_OK) { + vpx_internal_error(&cm->error, codec_status, + "vp9_extrc_get_encodeframe_decision() failed"); + } + q = encode_frame_decision.q_index; + ext_rc_max_frame_size = encode_frame_decision.max_frame_size; } -#endif vp9_set_quantizer(cpi, q); @@ -4507,34 +4565,62 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest if (frame_over_shoot_limit == 0) frame_over_shoot_limit = 1; } -#if CONFIG_RATE_CTRL - // This part needs to be after save_coding_context() because - // restore_coding_context will be called in the end of this function. - // TODO(angiebird): This is a hack for making sure the encoder use the - // external_quantize_index exactly. Avoid this kind of hack later. - if (cpi->encode_command.use_external_quantize_index) { - break; + if (cpi->ext_ratectrl.ready) { + last_q_attempt = q; + // In general, for the external rate control, we take the qindex provided + // as input and encode the frame with this qindex faithfully. However, + // in some extreme scenarios, the provided qindex leads to a massive + // overshoot of frame size. In this case, we fall back to VP9's decision + // to pick a new qindex and recode the frame. We return the new qindex + // through the API to the external model. + if (ext_rc_max_frame_size == 0) { + break; + } else if (ext_rc_max_frame_size == -1) { + if (rc->projected_frame_size < rc->max_frame_bandwidth) { + break; + } + } else { + if (rc->projected_frame_size < ext_rc_max_frame_size) { + break; + } + } + rc->max_frame_bandwidth = ext_rc_max_frame_size; + // If the current frame size exceeds the ext_rc_max_frame_size, + // we adjust the worst qindex to meet the frame size constraint. + q_high = 255; + ext_rc_recode = 1; } +#if CONFIG_RATE_CTRL + if (cpi->oxcf.use_simple_encode_api) { + // This part needs to be after save_coding_context() because + // restore_coding_context will be called in the end of this function. + // TODO(angiebird): This is a hack for making sure the encoder use the + // external_quantize_index exactly. Avoid this kind of hack later. + if (cpi->encode_command.use_external_quantize_index) { + break; + } - if (cpi->encode_command.use_external_target_frame_bits) { - const double percent_diff = get_bits_percent_diff( - rc->this_frame_target, rc->projected_frame_size); - update_rq_history(rq_history, rc->this_frame_target, - rc->projected_frame_size, q); - loop_count += 1; + if (cpi->encode_command.use_external_target_frame_bits) { + const double percent_diff = get_bits_percent_diff( + rc->this_frame_target, rc->projected_frame_size); + update_rq_history(rq_history, rc->this_frame_target, + rc->projected_frame_size, q); + loop_count += 1; - rq_model_update(rq_history, rc->this_frame_target, rq_model); + rq_model_update(rq_history, rc->this_frame_target, rq_model); - // Check if we hit the target bitrate. - if (percent_diff <= cpi->encode_command.target_frame_bits_error_percent || - rq_history->recode_count >= RATE_CTRL_MAX_RECODE_NUM || - rq_history->q_index_low >= rq_history->q_index_high) { - break; - } + // Check if we hit the target bitrate. + if (percent_diff <= + cpi->encode_command.target_frame_bits_error_percent || + rq_history->recode_count >= RATE_CTRL_MAX_RECODE_NUM || + rq_history->q_index_low >= rq_history->q_index_high) { + break; + } - loop = 1; - restore_coding_context(cpi); - continue; + loop = 1; + restore_coding_context(cpi); + continue; + } } #endif // CONFIG_RATE_CTRL @@ -4704,6 +4790,23 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest rc->projected_frame_size < rc->max_frame_bandwidth) loop = 0; + // Special handling of external max frame size constraint + if (ext_rc_recode) { + // If the largest q is not able to meet the max frame size limit, + // do nothing. + if (rc->projected_frame_size > ext_rc_max_frame_size && + last_q_attempt == 255) { + break; + } + // If VP9's q selection leads to a smaller q, we force it to use + // a larger q to better approximate the external max frame size + // constraint. + if (rc->projected_frame_size > ext_rc_max_frame_size && + q <= last_q_attempt) { + q = VPXMIN(255, last_q_attempt + 1); + } + } + if (loop) { ++loop_count; ++loop_at_this_size; @@ -4717,6 +4820,8 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest if (loop) restore_coding_context(cpi); } while (loop); + rc->max_frame_bandwidth = orig_rc_max_frame_bandwidth; + #ifdef AGGRESSIVE_VBR if (two_pass_first_group_inter(cpi)) { cpi->twopass.active_worst_quality = @@ -4751,27 +4856,6 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest } #endif // !CONFIG_REALTIME_ONLY -static int get_ref_frame_flags(const VP9_COMP *cpi) { - const int *const map = cpi->common.ref_frame_map; - const int gold_is_last = map[cpi->gld_fb_idx] == map[cpi->lst_fb_idx]; - const int alt_is_last = map[cpi->alt_fb_idx] == map[cpi->lst_fb_idx]; - const int gold_is_alt = map[cpi->gld_fb_idx] == map[cpi->alt_fb_idx]; - int flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; - - if (gold_is_last) flags &= ~VP9_GOLD_FLAG; - - if (cpi->rc.frames_till_gf_update_due == INT_MAX && - (cpi->svc.number_temporal_layers == 1 && - cpi->svc.number_spatial_layers == 1)) - flags &= ~VP9_GOLD_FLAG; - - if (alt_is_last) flags &= ~VP9_ALT_FLAG; - - if (gold_is_alt) flags &= ~VP9_ALT_FLAG; - - return flags; -} - static void set_ext_overrides(VP9_COMP *cpi) { // Overrides the defaults with the externally supplied values with // vp9_update_reference() and vp9_update_entropy() calls @@ -5076,9 +5160,7 @@ static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) { const GF_GROUP *const gf_group = &cpi->twopass.gf_group; ref_buffer->frame_index = cm->current_video_frame + gf_group->arf_src_offset[gf_group->index]; -#if CONFIG_RATE_CTRL ref_buffer->frame_coding_index = cm->current_frame_coding_index; -#endif // CONFIG_RATE_CTRL } } @@ -5273,16 +5355,81 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) { } #if !CONFIG_REALTIME_ONLY -static void update_encode_frame_result( +static void update_encode_frame_result_basic( + FRAME_UPDATE_TYPE update_type, int show_idx, int quantize_index, + ENCODE_FRAME_RESULT *encode_frame_result) { + encode_frame_result->show_idx = show_idx; + encode_frame_result->update_type = update_type; + encode_frame_result->quantize_index = quantize_index; +} + +#if CONFIG_RATE_CTRL +static void yv12_buffer_to_image_buffer(const YV12_BUFFER_CONFIG *yv12_buffer, + IMAGE_BUFFER *image_buffer) { + const uint8_t *src_buf_ls[3] = { yv12_buffer->y_buffer, yv12_buffer->u_buffer, + yv12_buffer->v_buffer }; + const int src_stride_ls[3] = { yv12_buffer->y_stride, yv12_buffer->uv_stride, + yv12_buffer->uv_stride }; + const int w_ls[3] = { yv12_buffer->y_crop_width, yv12_buffer->uv_crop_width, + yv12_buffer->uv_crop_width }; + const int h_ls[3] = { yv12_buffer->y_crop_height, yv12_buffer->uv_crop_height, + yv12_buffer->uv_crop_height }; + int plane; + for (plane = 0; plane < 3; ++plane) { + const int src_stride = src_stride_ls[plane]; + const int w = w_ls[plane]; + const int h = h_ls[plane]; + const uint8_t *src_buf = src_buf_ls[plane]; + uint8_t *dst_buf = image_buffer->plane_buffer[plane]; + int r; + assert(image_buffer->plane_width[plane] == w); + assert(image_buffer->plane_height[plane] == h); + for (r = 0; r < h; ++r) { + memcpy(dst_buf, src_buf, sizeof(*src_buf) * w); + src_buf += src_stride; + dst_buf += w; + } + } +} +// This function will update extra information specific for simple_encode APIs +static void update_encode_frame_result_simple_encode( int ref_frame_flags, FRAME_UPDATE_TYPE update_type, const YV12_BUFFER_CONFIG *source_frame, const RefCntBuffer *coded_frame_buf, - RefCntBuffer *ref_frame_buf[MAX_INTER_REF_FRAMES], int quantize_index, + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int quantize_index, uint32_t bit_depth, uint32_t input_bit_depth, const FRAME_COUNTS *counts, -#if CONFIG_RATE_CTRL const PARTITION_INFO *partition_info, const MOTION_VECTOR_INFO *motion_vector_info, + const TplDepStats *tpl_stats_info, + ENCODE_FRAME_RESULT *encode_frame_result) { + PSNR_STATS psnr; + update_encode_frame_result_basic(update_type, coded_frame_buf->frame_index, + quantize_index, encode_frame_result); +#if CONFIG_VP9_HIGHBITDEPTH + vpx_calc_highbd_psnr(source_frame, &coded_frame_buf->buf, &psnr, bit_depth, + input_bit_depth); +#else // CONFIG_VP9_HIGHBITDEPTH + (void)bit_depth; + (void)input_bit_depth; + vpx_calc_psnr(source_frame, &coded_frame_buf->buf, &psnr); +#endif // CONFIG_VP9_HIGHBITDEPTH + encode_frame_result->frame_coding_index = coded_frame_buf->frame_coding_index; + + vp9_get_ref_frame_info(update_type, ref_frame_flags, ref_frame_bufs, + encode_frame_result->ref_frame_coding_indexes, + encode_frame_result->ref_frame_valid_list); + + encode_frame_result->psnr = psnr.psnr[0]; + encode_frame_result->sse = psnr.sse[0]; + encode_frame_result->frame_counts = *counts; + encode_frame_result->partition_info = partition_info; + encode_frame_result->motion_vector_info = motion_vector_info; + encode_frame_result->tpl_stats_info = tpl_stats_info; + if (encode_frame_result->coded_frame.allocated) { + yv12_buffer_to_image_buffer(&coded_frame_buf->buf, + &encode_frame_result->coded_frame); + } +} #endif // CONFIG_RATE_CTRL - ENCODE_FRAME_RESULT *encode_frame_result); #endif // !CONFIG_REALTIME_ONLY static void encode_frame_to_data_rate( @@ -5377,10 +5524,14 @@ static void encode_frame_to_data_rate( memset(cpi->mode_chosen_counts, 0, MAX_MODES * sizeof(*cpi->mode_chosen_counts)); #endif -#if CONFIG_CONSISTENT_RECODE || CONFIG_RATE_CTRL +#if CONFIG_CONSISTENT_RECODE // Backup to ensure consistency between recodes save_encode_params(cpi); -#endif // CONFIG_CONSISTENT_RECODE || CONFIG_RATE_CTRL +#elif CONFIG_RATE_CTRL + if (cpi->oxcf.use_simple_encode_api) { + save_encode_params(cpi); + } +#endif if (cpi->sf.recode_loop == DISALLOW_RECODE) { if (!encode_without_recode_loop(cpi, size, dest)) return; @@ -5456,15 +5607,28 @@ static void encode_frame_to_data_rate( // build the bitstream vp9_pack_bitstream(cpi, dest, size); + { + const RefCntBuffer *coded_frame_buf = + get_ref_cnt_buffer(cm, cm->new_fb_idx); + vpx_codec_err_t codec_status = vp9_extrc_update_encodeframe_result( + &cpi->ext_ratectrl, (*size) << 3, cpi->Source, &coded_frame_buf->buf, + cm->bit_depth, cpi->oxcf.input_bit_depth, cm->base_qindex); + if (codec_status != VPX_CODEC_OK) { + vpx_internal_error(&cm->error, codec_status, + "vp9_extrc_update_encodeframe_result() failed"); + } + } #if CONFIG_REALTIME_ONLY (void)encode_frame_result; assert(encode_frame_result == NULL); #else // CONFIG_REALTIME_ONLY if (encode_frame_result != NULL) { - const int ref_frame_flags = get_ref_frame_flags(cpi); const RefCntBuffer *coded_frame_buf = get_ref_cnt_buffer(cm, cm->new_fb_idx); RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES]; + FRAME_UPDATE_TYPE update_type = + cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index]; + int quantize_index = vp9_get_quantizer(cpi); get_ref_frame_bufs(cpi, ref_frame_bufs); // update_encode_frame_result() depends on twopass.gf_group.index and // cm->new_fb_idx, cpi->Source, cpi->lst_fb_idx, cpi->gld_fb_idx and @@ -5482,15 +5646,21 @@ static void encode_frame_to_data_rate( // This function needs to be called before vp9_update_reference_frames(). // TODO(angiebird): Improve the codebase to make the update of frame // dependent variables more robust. - update_encode_frame_result( - ref_frame_flags, - cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index], - cpi->Source, coded_frame_buf, ref_frame_bufs, vp9_get_quantizer(cpi), - cpi->oxcf.input_bit_depth, cm->bit_depth, cpi->td.counts, + + update_encode_frame_result_basic(update_type, coded_frame_buf->frame_index, + quantize_index, encode_frame_result); #if CONFIG_RATE_CTRL - cpi->partition_info, cpi->motion_vector_info, + if (cpi->oxcf.use_simple_encode_api) { + const int ref_frame_flags = get_ref_frame_flags(cpi); + update_encode_frame_result_simple_encode( + ref_frame_flags, + cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index], + cpi->Source, coded_frame_buf, ref_frame_bufs, quantize_index, + cm->bit_depth, cpi->oxcf.input_bit_depth, cpi->td.counts, + cpi->partition_info, cpi->motion_vector_info, cpi->tpl_stats_info, + encode_frame_result); + } #endif // CONFIG_RATE_CTRL - encode_frame_result); } #endif // CONFIG_REALTIME_ONLY @@ -5556,7 +5726,8 @@ static void encode_frame_to_data_rate( vp9_rc_postencode_update(cpi, *size); - if (oxcf->pass == 0 && !frame_is_intra_only(cm) && + if (cpi->compute_frame_low_motion_onepass && oxcf->pass == 0 && + !frame_is_intra_only(cm) && (!cpi->use_svc || (cpi->use_svc && !cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame && @@ -5643,6 +5814,16 @@ static void Pass2Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest, unsigned int *frame_flags, ENCODE_FRAME_RESULT *encode_frame_result) { cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED; + + if (cpi->common.current_frame_coding_index == 0) { + VP9_COMMON *cm = &cpi->common; + const vpx_codec_err_t codec_status = vp9_extrc_send_firstpass_stats( + &cpi->ext_ratectrl, &cpi->twopass.first_pass_info); + if (codec_status != VPX_CODEC_OK) { + vpx_internal_error(&cm->error, codec_status, + "vp9_extrc_send_firstpass_stats() failed"); + } + } #if CONFIG_MISMATCH_DEBUG mismatch_move_frame_idx_w(); #endif @@ -7334,6 +7515,48 @@ static void free_tpl_buffer(VP9_COMP *cpi) { } } +#if CONFIG_RATE_CTRL +static void accumulate_frame_tpl_stats(VP9_COMP *cpi) { + VP9_COMMON *const cm = &cpi->common; + const GF_GROUP *gf_group = &cpi->twopass.gf_group; + int show_frame_count = 0; + int frame_idx; + // Accumulate tpl stats for each frame in the current group of picture. + for (frame_idx = 1; frame_idx < gf_group->gf_group_size; ++frame_idx) { + TplDepFrame *tpl_frame = &cpi->tpl_stats[frame_idx]; + TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr; + const int tpl_stride = tpl_frame->stride; + int64_t intra_cost_base = 0; + int64_t inter_cost_base = 0; + int64_t mc_dep_cost_base = 0; + int64_t mc_ref_cost_base = 0; + int64_t mc_flow_base = 0; + int row, col; + + if (!tpl_frame->is_valid) continue; + + for (row = 0; row < cm->mi_rows && tpl_frame->is_valid; ++row) { + for (col = 0; col < cm->mi_cols; ++col) { + TplDepStats *this_stats = &tpl_stats[row * tpl_stride + col]; + intra_cost_base += this_stats->intra_cost; + inter_cost_base += this_stats->inter_cost; + mc_dep_cost_base += this_stats->mc_dep_cost; + mc_ref_cost_base += this_stats->mc_ref_cost; + mc_flow_base += this_stats->mc_flow; + } + } + + cpi->tpl_stats_info[show_frame_count].intra_cost = intra_cost_base; + cpi->tpl_stats_info[show_frame_count].inter_cost = inter_cost_base; + cpi->tpl_stats_info[show_frame_count].mc_dep_cost = mc_dep_cost_base; + cpi->tpl_stats_info[show_frame_count].mc_ref_cost = mc_ref_cost_base; + cpi->tpl_stats_info[show_frame_count].mc_flow = mc_flow_base; + + ++show_frame_count; + } +} +#endif // CONFIG_RATE_CTRL + static void setup_tpl_stats(VP9_COMP *cpi) { GF_PICTURE gf_picture[MAX_ARF_GOP_SIZE]; const GF_GROUP *gf_group = &cpi->twopass.gf_group; @@ -7356,177 +7579,18 @@ static void setup_tpl_stats(VP9_COMP *cpi) { dump_tpl_stats(cpi, tpl_group_frames, gf_group, gf_picture, cpi->tpl_bsize); #endif // DUMP_TPL_STATS #endif // CONFIG_NON_GREEDY_MV -} -#if !CONFIG_REALTIME_ONLY #if CONFIG_RATE_CTRL -static void copy_frame_counts(const FRAME_COUNTS *input_counts, - FRAME_COUNTS *output_counts) { - int i, j, k, l, m, n; - for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) { - for (j = 0; j < INTRA_MODES; ++j) { - output_counts->y_mode[i][j] = input_counts->y_mode[i][j]; - } - } - for (i = 0; i < INTRA_MODES; ++i) { - for (j = 0; j < INTRA_MODES; ++j) { - output_counts->uv_mode[i][j] = input_counts->uv_mode[i][j]; - } - } - for (i = 0; i < PARTITION_CONTEXTS; ++i) { - for (j = 0; j < PARTITION_TYPES; ++j) { - output_counts->partition[i][j] = input_counts->partition[i][j]; - } - } - for (i = 0; i < TX_SIZES; ++i) { - for (j = 0; j < PLANE_TYPES; ++j) { - for (k = 0; k < REF_TYPES; ++k) { - for (l = 0; l < COEF_BANDS; ++l) { - for (m = 0; m < COEFF_CONTEXTS; ++m) { - output_counts->eob_branch[i][j][k][l][m] = - input_counts->eob_branch[i][j][k][l][m]; - for (n = 0; n < UNCONSTRAINED_NODES + 1; ++n) { - output_counts->coef[i][j][k][l][m][n] = - input_counts->coef[i][j][k][l][m][n]; - } - } - } - } - } - } - for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) { - for (j = 0; j < SWITCHABLE_FILTERS; ++j) { - output_counts->switchable_interp[i][j] = - input_counts->switchable_interp[i][j]; - } - } - for (i = 0; i < INTER_MODE_CONTEXTS; ++i) { - for (j = 0; j < INTER_MODES; ++j) { - output_counts->inter_mode[i][j] = input_counts->inter_mode[i][j]; - } - } - for (i = 0; i < INTRA_INTER_CONTEXTS; ++i) { - for (j = 0; j < 2; ++j) { - output_counts->intra_inter[i][j] = input_counts->intra_inter[i][j]; - } - } - for (i = 0; i < COMP_INTER_CONTEXTS; ++i) { - for (j = 0; j < 2; ++j) { - output_counts->comp_inter[i][j] = input_counts->comp_inter[i][j]; - } - } - for (i = 0; i < REF_CONTEXTS; ++i) { - for (j = 0; j < 2; ++j) { - for (k = 0; k < 2; ++k) { - output_counts->single_ref[i][j][k] = input_counts->single_ref[i][j][k]; - } - } + if (cpi->oxcf.use_simple_encode_api) { + accumulate_frame_tpl_stats(cpi); } - for (i = 0; i < REF_CONTEXTS; ++i) { - for (j = 0; j < 2; ++j) { - output_counts->comp_ref[i][j] = input_counts->comp_ref[i][j]; - } - } - for (i = 0; i < SKIP_CONTEXTS; ++i) { - for (j = 0; j < 2; ++j) { - output_counts->skip[i][j] = input_counts->skip[i][j]; - } - } - for (i = 0; i < TX_SIZE_CONTEXTS; i++) { - for (j = 0; j < TX_SIZES; j++) { - output_counts->tx.p32x32[i][j] = input_counts->tx.p32x32[i][j]; - } - for (j = 0; j < TX_SIZES - 1; j++) { - output_counts->tx.p16x16[i][j] = input_counts->tx.p16x16[i][j]; - } - for (j = 0; j < TX_SIZES - 2; j++) { - output_counts->tx.p8x8[i][j] = input_counts->tx.p8x8[i][j]; - } - } - for (i = 0; i < TX_SIZES; i++) { - output_counts->tx.tx_totals[i] = input_counts->tx.tx_totals[i]; - } - for (i = 0; i < MV_JOINTS; i++) { - output_counts->mv.joints[i] = input_counts->mv.joints[i]; - } - for (k = 0; k < 2; k++) { - nmv_component_counts *const comps = &output_counts->mv.comps[k]; - const nmv_component_counts *const comps_t = &input_counts->mv.comps[k]; - for (i = 0; i < 2; i++) { - comps->sign[i] = comps_t->sign[i]; - comps->class0_hp[i] = comps_t->class0_hp[i]; - comps->hp[i] = comps_t->hp[i]; - } - for (i = 0; i < MV_CLASSES; i++) { - comps->classes[i] = comps_t->classes[i]; - } - for (i = 0; i < CLASS0_SIZE; i++) { - comps->class0[i] = comps_t->class0[i]; - for (j = 0; j < MV_FP_SIZE; j++) { - comps->class0_fp[i][j] = comps_t->class0_fp[i][j]; - } - } - for (i = 0; i < MV_OFFSET_BITS; i++) { - for (j = 0; j < 2; j++) { - comps->bits[i][j] = comps_t->bits[i][j]; - } - } - for (i = 0; i < MV_FP_SIZE; i++) { - comps->fp[i] = comps_t->fp[i]; - } - } -} - -static void yv12_buffer_to_image_buffer(const YV12_BUFFER_CONFIG *yv12_buffer, - IMAGE_BUFFER *image_buffer) { - const uint8_t *src_buf_ls[3] = { yv12_buffer->y_buffer, yv12_buffer->u_buffer, - yv12_buffer->v_buffer }; - const int src_stride_ls[3] = { yv12_buffer->y_stride, yv12_buffer->uv_stride, - yv12_buffer->uv_stride }; - const int w_ls[3] = { yv12_buffer->y_crop_width, yv12_buffer->uv_crop_width, - yv12_buffer->uv_crop_width }; - const int h_ls[3] = { yv12_buffer->y_crop_height, yv12_buffer->uv_crop_height, - yv12_buffer->uv_crop_height }; - int plane; - for (plane = 0; plane < 3; ++plane) { - const int src_stride = src_stride_ls[plane]; - const int w = w_ls[plane]; - const int h = h_ls[plane]; - const uint8_t *src_buf = src_buf_ls[plane]; - uint8_t *dst_buf = image_buffer->plane_buffer[plane]; - int r; - assert(image_buffer->plane_width[plane] == w); - assert(image_buffer->plane_height[plane] == h); - for (r = 0; r < h; ++r) { - memcpy(dst_buf, src_buf, sizeof(*src_buf) * w); - src_buf += src_stride; - dst_buf += w; - } - } -} -#endif // CONFIG_RATE_CTRL -static void update_encode_frame_result( - int ref_frame_flags, FRAME_UPDATE_TYPE update_type, - const YV12_BUFFER_CONFIG *source_frame, const RefCntBuffer *coded_frame_buf, - RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int quantize_index, - uint32_t bit_depth, uint32_t input_bit_depth, const FRAME_COUNTS *counts, -#if CONFIG_RATE_CTRL - const PARTITION_INFO *partition_info, - const MOTION_VECTOR_INFO *motion_vector_info, #endif // CONFIG_RATE_CTRL - ENCODE_FRAME_RESULT *encode_frame_result) { -#if CONFIG_RATE_CTRL - PSNR_STATS psnr; -#if CONFIG_VP9_HIGHBITDEPTH - vpx_calc_highbd_psnr(source_frame, coded_frame_buf->buf, &psnr, bit_depth, - input_bit_depth); -#else // CONFIG_VP9_HIGHBITDEPTH - (void)bit_depth; - (void)input_bit_depth; - vpx_calc_psnr(source_frame, &coded_frame_buf->buf, &psnr); -#endif // CONFIG_VP9_HIGHBITDEPTH - encode_frame_result->frame_coding_index = coded_frame_buf->frame_coding_index; +} +void vp9_get_ref_frame_info(FRAME_UPDATE_TYPE update_type, int ref_frame_flags, + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], + int *ref_frame_coding_indexes, + int *ref_frame_valid_list) { if (update_type != KF_UPDATE) { const VP9_REFFRAME inter_ref_flags[MAX_INTER_REF_FRAMES] = { VP9_LAST_FLAG, VP9_GOLD_FLAG, @@ -7534,42 +7598,18 @@ static void update_encode_frame_result( int i; for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) { assert(ref_frame_bufs[i] != NULL); - encode_frame_result->ref_frame_coding_indexes[i] = - ref_frame_bufs[i]->frame_coding_index; - encode_frame_result->ref_frame_valid_list[i] = - (ref_frame_flags & inter_ref_flags[i]) != 0; + ref_frame_coding_indexes[i] = ref_frame_bufs[i]->frame_coding_index; + ref_frame_valid_list[i] = (ref_frame_flags & inter_ref_flags[i]) != 0; } } else { // No reference frame is available when this is a key frame. int i; for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) { - encode_frame_result->ref_frame_coding_indexes[i] = -1; - encode_frame_result->ref_frame_valid_list[i] = 0; + ref_frame_coding_indexes[i] = -1; + ref_frame_valid_list[i] = 0; } } - encode_frame_result->psnr = psnr.psnr[0]; - encode_frame_result->sse = psnr.sse[0]; - copy_frame_counts(counts, &encode_frame_result->frame_counts); - encode_frame_result->partition_info = partition_info; - encode_frame_result->motion_vector_info = motion_vector_info; - if (encode_frame_result->coded_frame.allocated) { - yv12_buffer_to_image_buffer(&coded_frame_buf->buf, - &encode_frame_result->coded_frame); - } -#else // CONFIG_RATE_CTRL - (void)ref_frame_flags; - (void)bit_depth; - (void)input_bit_depth; - (void)source_frame; - (void)coded_frame_buf; - (void)ref_frame_bufs; - (void)counts; -#endif // CONFIG_RATE_CTRL - encode_frame_result->show_idx = coded_frame_buf->frame_index; - encode_frame_result->update_type = update_type; - encode_frame_result->quantize_index = quantize_index; } -#endif // !CONFIG_REALTIME_ONLY void vp9_init_encode_frame_result(ENCODE_FRAME_RESULT *encode_frame_result) { encode_frame_result->show_idx = -1; // Actual encoding doesn't happen. @@ -7764,9 +7804,12 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, cm->new_fb_idx = get_free_fb(cm); if (cm->new_fb_idx == INVALID_IDX) return -1; - cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx]; - + // If the frame buffer for current frame is the same as previous frame, MV in + // the base layer shouldn't be used as it'll cause data race. + if (cpi->svc.spatial_layer_id > 0 && cm->cur_frame == cm->prev_frame) { + cpi->svc.use_base_mv = 0; + } // Start with a 0 size frame. *size = 0; diff --git a/third_party/libvpx/vp9/encoder/vp9_encoder.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h similarity index 96% rename from third_party/libvpx/vp9/encoder/vp9_encoder.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h index b201e25c1643..9774a64ccfcc 100644 --- a/third_party/libvpx/vp9/encoder/vp9_encoder.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h @@ -15,6 +15,7 @@ #include "./vpx_config.h" #include "vpx/internal/vpx_codec_internal.h" +#include "vpx/vpx_ext_ratectrl.h" #include "vpx/vp8cx.h" #if CONFIG_INTERNAL_STATS #include "vpx_dsp/ssim.h" @@ -38,6 +39,7 @@ #include "vp9/encoder/vp9_context_tree.h" #include "vp9/encoder/vp9_encodemb.h" #include "vp9/encoder/vp9_ethread.h" +#include "vp9/encoder/vp9_ext_ratectrl.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_job_queue.h" #include "vp9/encoder/vp9_lookahead.h" @@ -147,6 +149,12 @@ typedef enum { kVeryHighSad = 6, } CONTENT_STATE_SB; +typedef enum { + LOOPFILTER_ALL = 0, + LOOPFILTER_REFERENCE = 1, // Disable loopfilter on non reference frames. + NO_LOOPFILTER = 2, // Disable loopfilter on all frames. +} LOOPFILTER_CONTROL; + typedef struct VP9EncoderConfig { BITSTREAM_PROFILE profile; vpx_bit_depth_t bit_depth; // Codec bit-depth. @@ -265,10 +273,6 @@ typedef struct VP9EncoderConfig { vpx_fixed_buf_t two_pass_stats_in; -#if CONFIG_FP_MB_STATS - vpx_fixed_buf_t firstpass_mb_stats_in; -#endif - vp8e_tuning tuning; vp9e_tune_content content; #if CONFIG_VP9_HIGHBITDEPTH @@ -283,6 +287,7 @@ typedef struct VP9EncoderConfig { int row_mt; unsigned int motion_vector_unit_test; int delta_q_uv; + int use_simple_encode_api; // Use SimpleEncode APIs or not } VP9EncoderConfig; static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) { @@ -702,9 +707,6 @@ typedef struct VP9_COMP { TileDataEnc *tile_data; int allocated_tiles; // Keep track of memory allocated for tiles. - // For a still frame, this flag is set to 1 to skip partition search. - int partition_search_skippable_frame; - int scaled_ref_idx[REFS_PER_FRAME]; int lst_fb_idx; int gld_fb_idx; @@ -738,6 +740,7 @@ typedef struct VP9_COMP { // Ambient reconstruction err target for force key frames int64_t ambient_err; + RD_CONTROL rd_ctrl; RD_OPT rd; CODING_CONTEXT coding_context; @@ -796,10 +799,6 @@ typedef struct VP9_COMP { uint64_t time_pick_lpf; uint64_t time_encode_sb_row; -#if CONFIG_FP_MB_STATS - int use_fp_mb_stats; -#endif - TWO_PASS twopass; // Force recalculation of segment_ids for each mode info @@ -951,6 +950,8 @@ typedef struct VP9_COMP { int compute_source_sad_onepass; + int compute_frame_low_motion_onepass; + LevelConstraint level_constraint; uint8_t *count_arf_frame_usage; @@ -958,14 +959,18 @@ typedef struct VP9_COMP { int multi_layer_arf; vpx_roi_map_t roi; + + LOOPFILTER_CONTROL loopfilter_ctrl; #if CONFIG_RATE_CTRL ENCODE_COMMAND encode_command; PARTITION_INFO *partition_info; MOTION_VECTOR_INFO *motion_vector_info; MOTION_VECTOR_INFO *fp_motion_vector_info; + TplDepStats *tpl_stats_info; RATE_QSTEP_MODEL rq_model[ENCODE_FRAME_TYPES]; #endif + EXT_RATECTRL ext_ratectrl; } VP9_COMP; #if CONFIG_RATE_CTRL @@ -1018,6 +1023,23 @@ static INLINE void free_motion_vector_info(struct VP9_COMP *cpi) { cpi->motion_vector_info = NULL; } +// Allocates memory for the tpl stats information. +// Only called once in vp9_create_compressor(). +static INLINE void tpl_stats_info_init(struct VP9_COMP *cpi) { + VP9_COMMON *const cm = &cpi->common; + CHECK_MEM_ERROR( + cm, cpi->tpl_stats_info, + (TplDepStats *)vpx_calloc(MAX_LAG_BUFFERS, sizeof(TplDepStats))); + memset(cpi->tpl_stats_info, 0, MAX_LAG_BUFFERS * sizeof(TplDepStats)); +} + +// Frees memory of the tpl stats information. +// Only called once in dealloc_compressor_data(). +static INLINE void free_tpl_stats_info(struct VP9_COMP *cpi) { + vpx_free(cpi->tpl_stats_info); + cpi->tpl_stats_info = NULL; +} + // Allocates memory for the first pass motion vector information. // The unit size is each 16x16 block. // Only called once in vp9_create_compressor(). @@ -1080,6 +1102,7 @@ typedef struct ENCODE_FRAME_RESULT { FRAME_COUNTS frame_counts; const PARTITION_INFO *partition_info; const MOTION_VECTOR_INFO *motion_vector_info; + const TplDepStats *tpl_stats_info; IMAGE_BUFFER coded_frame; RATE_QINDEX_HISTORY rq_history; #endif // CONFIG_RATE_CTRL @@ -1257,6 +1280,11 @@ void vp9_scale_references(VP9_COMP *cpi); void vp9_update_reference_frames(VP9_COMP *cpi); +void vp9_get_ref_frame_info(FRAME_UPDATE_TYPE update_type, int ref_frame_flags, + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], + int *ref_frame_coding_indexes, + int *ref_frame_valid_list); + void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv); YV12_BUFFER_CONFIG *vp9_svc_twostage_scale( diff --git a/third_party/libvpx/vp9/encoder/vp9_ethread.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ethread.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_ethread.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_ethread.c diff --git a/third_party/libvpx/vp9/encoder/vp9_ethread.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ethread.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_ethread.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_ethread.h diff --git a/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.c new file mode 100644 index 000000000000..9f0098ab5a00 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.c @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "vp9/encoder/vp9_ext_ratectrl.h" +#include "vp9/encoder/vp9_encoder.h" +#include "vp9/common/vp9_common.h" +#include "vpx_dsp/psnr.h" + +vpx_codec_err_t vp9_extrc_init(EXT_RATECTRL *ext_ratectrl) { + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + vp9_zero(*ext_ratectrl); + return VPX_CODEC_OK; +} + +vpx_codec_err_t vp9_extrc_create(vpx_rc_funcs_t funcs, + vpx_rc_config_t ratectrl_config, + EXT_RATECTRL *ext_ratectrl) { + vpx_rc_status_t rc_status; + vpx_rc_firstpass_stats_t *rc_firstpass_stats; + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + vp9_extrc_delete(ext_ratectrl); + ext_ratectrl->funcs = funcs; + ext_ratectrl->ratectrl_config = ratectrl_config; + rc_status = ext_ratectrl->funcs.create_model(ext_ratectrl->funcs.priv, + &ext_ratectrl->ratectrl_config, + &ext_ratectrl->model); + if (rc_status == VPX_RC_ERROR) { + return VPX_CODEC_ERROR; + } + rc_firstpass_stats = &ext_ratectrl->rc_firstpass_stats; + rc_firstpass_stats->num_frames = ratectrl_config.show_frame_count; + rc_firstpass_stats->frame_stats = + vpx_malloc(sizeof(*rc_firstpass_stats->frame_stats) * + rc_firstpass_stats->num_frames); + if (rc_firstpass_stats->frame_stats == NULL) { + return VPX_CODEC_MEM_ERROR; + } + ext_ratectrl->ready = 1; + return VPX_CODEC_OK; +} + +vpx_codec_err_t vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl) { + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + if (ext_ratectrl->ready) { + vpx_rc_status_t rc_status = + ext_ratectrl->funcs.delete_model(ext_ratectrl->model); + if (rc_status == VPX_RC_ERROR) { + return VPX_CODEC_ERROR; + } + vpx_free(ext_ratectrl->rc_firstpass_stats.frame_stats); + } + return vp9_extrc_init(ext_ratectrl); +} + +static void gen_rc_firstpass_stats(const FIRSTPASS_STATS *stats, + vpx_rc_frame_stats_t *rc_frame_stats) { + rc_frame_stats->frame = stats->frame; + rc_frame_stats->weight = stats->weight; + rc_frame_stats->intra_error = stats->intra_error; + rc_frame_stats->coded_error = stats->coded_error; + rc_frame_stats->sr_coded_error = stats->sr_coded_error; + rc_frame_stats->frame_noise_energy = stats->frame_noise_energy; + rc_frame_stats->pcnt_inter = stats->pcnt_inter; + rc_frame_stats->pcnt_motion = stats->pcnt_motion; + rc_frame_stats->pcnt_second_ref = stats->pcnt_second_ref; + rc_frame_stats->pcnt_neutral = stats->pcnt_neutral; + rc_frame_stats->pcnt_intra_low = stats->pcnt_intra_low; + rc_frame_stats->pcnt_intra_high = stats->pcnt_intra_high; + rc_frame_stats->intra_skip_pct = stats->intra_skip_pct; + rc_frame_stats->intra_smooth_pct = stats->intra_smooth_pct; + rc_frame_stats->inactive_zone_rows = stats->inactive_zone_rows; + rc_frame_stats->inactive_zone_cols = stats->inactive_zone_cols; + rc_frame_stats->MVr = stats->MVr; + rc_frame_stats->mvr_abs = stats->mvr_abs; + rc_frame_stats->MVc = stats->MVc; + rc_frame_stats->mvc_abs = stats->mvc_abs; + rc_frame_stats->MVrv = stats->MVrv; + rc_frame_stats->MVcv = stats->MVcv; + rc_frame_stats->mv_in_out_count = stats->mv_in_out_count; + rc_frame_stats->duration = stats->duration; + rc_frame_stats->count = stats->count; +} + +vpx_codec_err_t vp9_extrc_send_firstpass_stats( + EXT_RATECTRL *ext_ratectrl, const FIRST_PASS_INFO *first_pass_info) { + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + if (ext_ratectrl->ready) { + vpx_rc_status_t rc_status; + vpx_rc_firstpass_stats_t *rc_firstpass_stats = + &ext_ratectrl->rc_firstpass_stats; + int i; + assert(rc_firstpass_stats->num_frames == first_pass_info->num_frames); + for (i = 0; i < rc_firstpass_stats->num_frames; ++i) { + gen_rc_firstpass_stats(&first_pass_info->stats[i], + &rc_firstpass_stats->frame_stats[i]); + } + rc_status = ext_ratectrl->funcs.send_firstpass_stats(ext_ratectrl->model, + rc_firstpass_stats); + if (rc_status == VPX_RC_ERROR) { + return VPX_CODEC_ERROR; + } + } + return VPX_CODEC_OK; +} + +static int extrc_get_frame_type(FRAME_UPDATE_TYPE update_type) { + // TODO(angiebird): Add unit test to make sure this function behaves like + // get_frame_type_from_update_type() + // TODO(angiebird): Merge this function with get_frame_type_from_update_type() + switch (update_type) { + case KF_UPDATE: return 0; // kFrameTypeKey; + case ARF_UPDATE: return 2; // kFrameTypeAltRef; + case GF_UPDATE: return 4; // kFrameTypeGolden; + case OVERLAY_UPDATE: return 3; // kFrameTypeOverlay; + case LF_UPDATE: return 1; // kFrameTypeInter; + default: + fprintf(stderr, "Unsupported update_type %d\n", update_type); + abort(); + return 1; + } +} + +vpx_codec_err_t vp9_extrc_get_encodeframe_decision( + EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index, int gop_index, + FRAME_UPDATE_TYPE update_type, + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int ref_frame_flags, + vpx_rc_encodeframe_decision_t *encode_frame_decision) { + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + if (ext_ratectrl->ready) { + vpx_rc_status_t rc_status; + vpx_rc_encodeframe_info_t encode_frame_info; + encode_frame_info.show_index = show_index; + encode_frame_info.coding_index = coding_index; + encode_frame_info.gop_index = gop_index; + encode_frame_info.frame_type = extrc_get_frame_type(update_type); + + vp9_get_ref_frame_info(update_type, ref_frame_flags, ref_frame_bufs, + encode_frame_info.ref_frame_coding_indexes, + encode_frame_info.ref_frame_valid_list); + + rc_status = ext_ratectrl->funcs.get_encodeframe_decision( + ext_ratectrl->model, &encode_frame_info, encode_frame_decision); + if (rc_status == VPX_RC_ERROR) { + return VPX_CODEC_ERROR; + } + } + return VPX_CODEC_OK; +} + +vpx_codec_err_t vp9_extrc_update_encodeframe_result( + EXT_RATECTRL *ext_ratectrl, int64_t bit_count, + const YV12_BUFFER_CONFIG *source_frame, + const YV12_BUFFER_CONFIG *coded_frame, uint32_t bit_depth, + uint32_t input_bit_depth, const int actual_encoding_qindex) { + if (ext_ratectrl == NULL) { + return VPX_CODEC_INVALID_PARAM; + } + if (ext_ratectrl->ready) { + PSNR_STATS psnr; + vpx_rc_status_t rc_status; + vpx_rc_encodeframe_result_t encode_frame_result; + encode_frame_result.bit_count = bit_count; + encode_frame_result.pixel_count = + source_frame->y_crop_width * source_frame->y_crop_height + + 2 * source_frame->uv_crop_width * source_frame->uv_crop_height; + encode_frame_result.actual_encoding_qindex = actual_encoding_qindex; +#if CONFIG_VP9_HIGHBITDEPTH + vpx_calc_highbd_psnr(source_frame, coded_frame, &psnr, bit_depth, + input_bit_depth); +#else + (void)bit_depth; + (void)input_bit_depth; + vpx_calc_psnr(source_frame, coded_frame, &psnr); +#endif + encode_frame_result.sse = psnr.sse[0]; + rc_status = ext_ratectrl->funcs.update_encodeframe_result( + ext_ratectrl->model, &encode_frame_result); + if (rc_status == VPX_RC_ERROR) { + return VPX_CODEC_ERROR; + } + } + return VPX_CODEC_OK; +} diff --git a/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h new file mode 100644 index 000000000000..74fd68b96d0a --- /dev/null +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_ +#define VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_ + +#include "vpx/vpx_ext_ratectrl.h" +#include "vp9/encoder/vp9_firstpass.h" + +typedef struct EXT_RATECTRL { + int ready; + vpx_rc_model_t model; + vpx_rc_funcs_t funcs; + vpx_rc_config_t ratectrl_config; + vpx_rc_firstpass_stats_t rc_firstpass_stats; +} EXT_RATECTRL; + +vpx_codec_err_t vp9_extrc_init(EXT_RATECTRL *ext_ratectrl); + +vpx_codec_err_t vp9_extrc_create(vpx_rc_funcs_t funcs, + vpx_rc_config_t ratectrl_config, + EXT_RATECTRL *ext_ratectrl); + +vpx_codec_err_t vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl); + +vpx_codec_err_t vp9_extrc_send_firstpass_stats( + EXT_RATECTRL *ext_ratectrl, const FIRST_PASS_INFO *first_pass_info); + +vpx_codec_err_t vp9_extrc_get_encodeframe_decision( + EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index, int gop_index, + FRAME_UPDATE_TYPE update_type, + RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int ref_frame_flags, + vpx_rc_encodeframe_decision_t *encode_frame_decision); + +vpx_codec_err_t vp9_extrc_update_encodeframe_result( + EXT_RATECTRL *ext_ratectrl, int64_t bit_count, + const YV12_BUFFER_CONFIG *source_frame, + const YV12_BUFFER_CONFIG *coded_frame, uint32_t bit_depth, + uint32_t input_bit_depth, const int actual_encoding_qindex); + +#endif // VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_ diff --git a/third_party/libvpx/vp9/encoder/vp9_extend.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_extend.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.c diff --git a/third_party/libvpx/vp9/encoder/vp9_extend.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_extend.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h diff --git a/third_party/libvpx/vp9/encoder/vp9_firstpass.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c similarity index 91% rename from third_party/libvpx/vp9/encoder/vp9_firstpass.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c index de954f7575ec..67302ed0352f 100644 --- a/third_party/libvpx/vp9/encoder/vp9_firstpass.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c @@ -54,6 +54,30 @@ #define NCOUNT_INTRA_THRESH 8192 #define NCOUNT_INTRA_FACTOR 3 +#define INTRA_PART 0.005 +#define DEFAULT_DECAY_LIMIT 0.75 +#define LOW_SR_DIFF_TRHESH 0.1 +#define LOW_CODED_ERR_PER_MB 10.0 +#define NCOUNT_FRAME_II_THRESH 6.0 +#define BASELINE_ERR_PER_MB 12500.0 +#define GF_MAX_FRAME_BOOST 96.0 + +#ifdef AGGRESSIVE_VBR +#define KF_MIN_FRAME_BOOST 40.0 +#define KF_MAX_FRAME_BOOST 80.0 +#define MAX_KF_TOT_BOOST 4800 +#else +#define KF_MIN_FRAME_BOOST 40.0 +#define KF_MAX_FRAME_BOOST 96.0 +#define MAX_KF_TOT_BOOST 5400 +#endif + +#define DEFAULT_ZM_FACTOR 0.5 +#define MINQ_ADJ_LIMIT 48 +#define MINQ_ADJ_LIMIT_CQ 20 +#define HIGH_UNDERSHOOT_RATIO 2 +#define AV_WQ_FACTOR 4.0 + #define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x)-0.000001 : (x) + 0.000001) #if ARF_STATS_OUTPUT @@ -111,17 +135,6 @@ static void output_stats(FIRSTPASS_STATS *stats) { #endif } -#if CONFIG_FP_MB_STATS -static void output_fpmb_stats(uint8_t *this_frame_mb_stats, VP9_COMMON *cm, - struct vpx_codec_pkt_list *pktlist) { - struct vpx_codec_cx_pkt pkt; - pkt.kind = VPX_CODEC_FPMB_STATS_PKT; - pkt.data.firstpass_mb_stats.buf = this_frame_mb_stats; - pkt.data.firstpass_mb_stats.sz = cm->initial_mbs * sizeof(uint8_t); - vpx_codec_pkt_list_add(pktlist, &pkt); -} -#endif - static void zero_stats(FIRSTPASS_STATS *section) { section->frame = 0.0; section->weight = 0.0; @@ -929,10 +942,6 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, int level_sample; const int mb_index = mb_row * cm->mb_cols + mb_col; -#if CONFIG_FP_MB_STATS - const int mb_index = mb_row * cm->mb_cols + mb_col; -#endif - (*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, mb_row, c); // Adjust to the next column of MBs. @@ -1068,21 +1077,14 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, // Accumulate the intra error. fp_acc_data->intra_error += (int64_t)this_error; -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - // initialization - cpi->twopass.frame_mb_stats_buf[mb_index] = 0; - } -#endif - // Set up limit values for motion vectors to prevent them extending // outside the UMV borders. x->mv_limits.col_min = -((mb_col * 16) + BORDER_MV_PIXELS_B16); x->mv_limits.col_max = ((cm->mb_cols - 1 - mb_col) * 16) + BORDER_MV_PIXELS_B16; - // Other than for the first frame do a motion search. - if (cm->current_video_frame > 0) { + // Other than for intra-only frame do a motion search. + if (!frame_is_intra_only(cm)) { int tmp_err, motion_error, this_motion_error, raw_motion_error; // Assume 0,0 motion with no mv overhead. MV mv = { 0, 0 }, tmp_mv = { 0, 0 }; @@ -1090,8 +1092,10 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize]; #if CONFIG_RATE_CTRL - // Store zero mv as default - store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); + if (cpi->oxcf.use_simple_encode_api) { + // Store zero mv as default + store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); + } #endif // CONFIG_RAGE_CTRL xd->plane[0].pre[0].buf = first_ref_buf->y_buffer + recon_yoffset; @@ -1159,7 +1163,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, } } #if CONFIG_RATE_CTRL - store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); + if (cpi->oxcf.use_simple_encode_api) { + store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); + } #endif // CONFIG_RAGE_CTRL // Search in an older reference frame. @@ -1183,7 +1189,10 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, first_pass_motion_search(cpi, x, &zero_mv, &tmp_mv, &gf_motion_error); #if CONFIG_RATE_CTRL - store_fp_motion_vector(cpi, &tmp_mv, mb_row, mb_col, GOLDEN_FRAME, 1); + if (cpi->oxcf.use_simple_encode_api) { + store_fp_motion_vector(cpi, &tmp_mv, mb_row, mb_col, GOLDEN_FRAME, + 1); + } #endif // CONFIG_RAGE_CTRL if (gf_motion_error < motion_error && gf_motion_error < this_error) @@ -1213,20 +1222,6 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, best_ref_mv->row = 0; best_ref_mv->col = 0; -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - // intra prediction statistics - cpi->twopass.frame_mb_stats_buf[mb_index] = 0; - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_DCINTRA_MASK; - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK; - if (this_error > FPMB_ERROR_LARGE_TH) { - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LARGE_MASK; - } else if (this_error < FPMB_ERROR_SMALL_TH) { - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_SMALL_MASK; - } - } -#endif - if (motion_error <= this_error) { vpx_clear_system_state(); @@ -1271,47 +1266,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, *best_ref_mv = mv; -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - // inter prediction statistics - cpi->twopass.frame_mb_stats_buf[mb_index] = 0; - cpi->twopass.frame_mb_stats_buf[mb_index] &= ~FPMB_DCINTRA_MASK; - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK; - if (this_error > FPMB_ERROR_LARGE_TH) { - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LARGE_MASK; - } else if (this_error < FPMB_ERROR_SMALL_TH) { - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_SMALL_MASK; - } - } -#endif - if (!is_zero_mv(&mv)) { ++(fp_acc_data->mvcount); -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - cpi->twopass.frame_mb_stats_buf[mb_index] &= ~FPMB_MOTION_ZERO_MASK; - // check estimated motion direction - if (mv.as_mv.col > 0 && mv.as_mv.col >= abs(mv.as_mv.row)) { - // right direction - cpi->twopass.frame_mb_stats_buf[mb_index] |= - FPMB_MOTION_RIGHT_MASK; - } else if (mv.as_mv.row < 0 && - abs(mv.as_mv.row) >= abs(mv.as_mv.col)) { - // up direction - cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_UP_MASK; - } else if (mv.as_mv.col < 0 && - abs(mv.as_mv.col) >= abs(mv.as_mv.row)) { - // left direction - cpi->twopass.frame_mb_stats_buf[mb_index] |= - FPMB_MOTION_LEFT_MASK; - } else { - // down direction - cpi->twopass.frame_mb_stats_buf[mb_index] |= - FPMB_MOTION_DOWN_MASK; - } - } -#endif // Does the row vector point inwards or outwards? if (mb_row < cm->mb_rows / 2) { if (mv.row > 0) @@ -1359,7 +1316,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, } else { fp_acc_data->sr_coded_error += (int64_t)this_error; #if CONFIG_RATE_CTRL - store_fp_motion_vector(cpi, NULL, mb_row, mb_col, INTRA_FRAME, 0); + if (cpi->oxcf.use_simple_encode_api) { + store_fp_motion_vector(cpi, NULL, mb_row, mb_col, INTRA_FRAME, 0); + } #endif // CONFIG_RAGE_CTRL } fp_acc_data->coded_error += (int64_t)this_error; @@ -1388,9 +1347,11 @@ static void first_pass_encode(VP9_COMP *cpi, FIRSTPASS_DATA *fp_acc_data) { vp9_tile_init(tile, cm, 0, 0); #if CONFIG_RATE_CTRL - fp_motion_vector_info_reset(cpi->frame_info.frame_width, - cpi->frame_info.frame_height, - cpi->fp_motion_vector_info); + if (cpi->oxcf.use_simple_encode_api) { + fp_motion_vector_info_reset(cpi->frame_info.frame_width, + cpi->frame_info.frame_height, + cpi->fp_motion_vector_info); + } #endif for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { @@ -1424,12 +1385,6 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { assert(new_yv12 != NULL); assert(frame_is_intra_only(cm) || (lst_yv12 != NULL)); -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - vp9_zero_array(cpi->twopass.frame_mb_stats_buf, cm->initial_mbs); - } -#endif - set_first_pass_params(cpi); vp9_set_quantizer(cpi, find_fp_qindex(cm->bit_depth)); @@ -1490,12 +1445,6 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { twopass->this_frame_stats = fps; output_stats(&twopass->this_frame_stats); accumulate_stats(&twopass->total_stats, &fps); - -#if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - output_fpmb_stats(twopass->frame_mb_stats_buf, cm, cpi->output_pkt_list); - } -#endif } // Copy the previous Last Frame back into gf and and arf buffers if @@ -1807,60 +1756,59 @@ void vp9_init_second_pass(VP9_COMP *cpi) { twopass->arnr_strength_adjustment = 0; } -#define SR_DIFF_PART 0.0015 -#define INTRA_PART 0.005 -#define DEFAULT_DECAY_LIMIT 0.75 -#define LOW_SR_DIFF_TRHESH 0.1 -#define SR_DIFF_MAX 128.0 -#define LOW_CODED_ERR_PER_MB 10.0 -#define NCOUNT_FRAME_II_THRESH 6.0 - -static double get_sr_decay_rate(const FRAME_INFO *frame_info, +/* This function considers how the quality of prediction may be deteriorating + * with distance. It compares the coded error for the last frame and the + * second reference frame (usually two frames old) and also applies a factor + * based on the extent of INTRA coding. + * + * The decay factor is then used to reduce the contribution of frames further + * from the alt-ref or golden frame, to the bitrate boost calculation for that + * alt-ref or golden frame. + */ +static double get_sr_decay_rate(const TWO_PASS *const twopass, const FIRSTPASS_STATS *frame) { double sr_diff = (frame->sr_coded_error - frame->coded_error); double sr_decay = 1.0; - double modified_pct_inter; - double modified_pcnt_intra; - const double motion_amplitude_part = - frame->pcnt_motion * - ((frame->mvc_abs + frame->mvr_abs) / - (frame_info->frame_height + frame_info->frame_width)); - - modified_pct_inter = frame->pcnt_inter; - if ((frame->coded_error > LOW_CODED_ERR_PER_MB) && - ((frame->intra_error / DOUBLE_DIVIDE_CHECK(frame->coded_error)) < - (double)NCOUNT_FRAME_II_THRESH)) { - modified_pct_inter = - frame->pcnt_inter + frame->pcnt_intra_low - frame->pcnt_neutral; - } - modified_pcnt_intra = 100 * (1.0 - modified_pct_inter); + // Do nothing if the second ref to last frame error difference is + // very small or even negative. if ((sr_diff > LOW_SR_DIFF_TRHESH)) { - sr_diff = VPXMIN(sr_diff, SR_DIFF_MAX); - sr_decay = 1.0 - (SR_DIFF_PART * sr_diff) - motion_amplitude_part - - (INTRA_PART * modified_pcnt_intra); + const double sr_diff_part = + twopass->sr_diff_factor * ((sr_diff * 0.25) / frame->intra_error); + double modified_pct_inter = frame->pcnt_inter; + double modified_pcnt_intra; + + if ((frame->coded_error > LOW_CODED_ERR_PER_MB) && + ((frame->intra_error / DOUBLE_DIVIDE_CHECK(frame->coded_error)) < + (double)NCOUNT_FRAME_II_THRESH)) { + modified_pct_inter = + frame->pcnt_inter + frame->pcnt_intra_low - frame->pcnt_neutral; + } + modified_pcnt_intra = 100 * (1.0 - modified_pct_inter); + + sr_decay = 1.0 - sr_diff_part - (INTRA_PART * modified_pcnt_intra); } - return VPXMAX(sr_decay, DEFAULT_DECAY_LIMIT); + return VPXMAX(sr_decay, twopass->sr_default_decay_limit); } // This function gives an estimate of how badly we believe the prediction // quality is decaying from frame to frame. -static double get_zero_motion_factor(const FRAME_INFO *frame_info, +static double get_zero_motion_factor(const TWO_PASS *const twopass, const FIRSTPASS_STATS *frame_stats) { const double zero_motion_pct = frame_stats->pcnt_inter - frame_stats->pcnt_motion; - double sr_decay = get_sr_decay_rate(frame_info, frame_stats); + double sr_decay = get_sr_decay_rate(twopass, frame_stats); return VPXMIN(sr_decay, zero_motion_pct); } -#define ZM_POWER_FACTOR 0.75 - -static double get_prediction_decay_rate(const FRAME_INFO *frame_info, +static double get_prediction_decay_rate(const TWO_PASS *const twopass, const FIRSTPASS_STATS *frame_stats) { - const double sr_decay_rate = get_sr_decay_rate(frame_info, frame_stats); - const double zero_motion_factor = - (0.95 * pow((frame_stats->pcnt_inter - frame_stats->pcnt_motion), - ZM_POWER_FACTOR)); + const double sr_decay_rate = get_sr_decay_rate(twopass, frame_stats); + double zero_motion_factor = + twopass->zm_factor * (frame_stats->pcnt_inter - frame_stats->pcnt_motion); + + // Check that the zero motion factor is valid + assert(zero_motion_factor >= 0.0 && zero_motion_factor <= 1.0); return VPXMAX(zero_motion_factor, (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor))); @@ -1942,10 +1890,9 @@ static void accumulate_frame_motion_stats(const FIRSTPASS_STATS *stats, } } -#define BASELINE_ERR_PER_MB 12500.0 -#define GF_MAX_BOOST 96.0 static double calc_frame_boost(const FRAME_INFO *frame_info, const FIRSTPASS_STATS *this_frame, + const TWO_PASS *const twopass, int avg_frame_qindex, double this_frame_mv_in_out) { double frame_boost; @@ -1954,8 +1901,8 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, const double boost_q_correction = VPXMIN((0.5 + (lq * 0.015)), 1.5); const double active_area = calculate_active_area(frame_info, this_frame); - // Underlying boost factor is based on inter error ratio. - frame_boost = (BASELINE_ERR_PER_MB * active_area) / + // Frame booost is based on inter error. + frame_boost = (twopass->err_per_mb * active_area) / DOUBLE_DIVIDE_CHECK(this_frame->coded_error); // Small adjustment for cases where there is a zoom out @@ -1965,37 +1912,25 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, // Q correction and scalling frame_boost = frame_boost * boost_q_correction; - return VPXMIN(frame_boost, GF_MAX_BOOST * boost_q_correction); -} - -static double kf_err_per_mb(VP9_COMP *cpi) { - const VP9_COMMON *const cm = &cpi->common; - unsigned int screen_area = (cm->width * cm->height); - - // Use a different error per mb factor for calculating boost for - // different formats. - if (screen_area < 1280 * 720) { - return 2000.0; - } else if (screen_area < 1920 * 1080) { - return 500.0; - } - return 250.0; + return VPXMIN(frame_boost, twopass->gf_frame_max_boost * boost_q_correction); } static double calc_kf_frame_boost(VP9_COMP *cpi, const FIRSTPASS_STATS *this_frame, double *sr_accumulator, double this_frame_mv_in_out, - double max_boost) { + double zm_factor) { + TWO_PASS *const twopass = &cpi->twopass; double frame_boost; const double lq = vp9_convert_qindex_to_q( cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth); const double boost_q_correction = VPXMIN((0.50 + (lq * 0.015)), 2.00); const double active_area = calculate_active_area(&cpi->frame_info, this_frame); + double max_boost; - // Underlying boost factor is based on inter error ratio. - frame_boost = (kf_err_per_mb(cpi) * active_area) / + // Frame booost is based on inter error. + frame_boost = (twopass->kf_err_per_mb * active_area) / DOUBLE_DIVIDE_CHECK(this_frame->coded_error + *sr_accumulator); // Update the accumulator for second ref error difference. @@ -2012,15 +1947,23 @@ static double calc_kf_frame_boost(VP9_COMP *cpi, // The 40.0 value here is an experimentally derived baseline minimum. // This value is in line with the minimum per frame boost in the alt_ref // boost calculation. - frame_boost = ((frame_boost + 40.0) * boost_q_correction); + frame_boost = + (frame_boost + twopass->kf_frame_min_boost) * boost_q_correction; - return VPXMIN(frame_boost, max_boost * boost_q_correction); + // Maximum allowed boost this frame. May be different for first vs subsequent + // key frames. + max_boost = (cpi->common.current_video_frame == 0) + ? twopass->kf_frame_max_boost_first + : twopass->kf_frame_max_boost_subs; + max_boost *= zm_factor * boost_q_correction; + + return VPXMIN(frame_boost, max_boost); } static int compute_arf_boost(const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int arf_show_idx, int f_frames, int b_frames, - int avg_frame_qindex) { + TWO_PASS *const twopass, int arf_show_idx, + int f_frames, int b_frames, int avg_frame_qindex) { + const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; int i; double boost_score = 0.0; double mv_ratio_accumulator = 0.0; @@ -2051,14 +1994,14 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, // Accumulate the effect of prediction quality decay. if (!flash_detected) { - decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame); + decay_accumulator *= get_prediction_decay_rate(twopass, this_frame); decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR ? MIN_DECAY_FACTOR : decay_accumulator; } - boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame, - avg_frame_qindex, - this_frame_mv_in_out); + boost_score += decay_accumulator * + calc_frame_boost(frame_info, this_frame, twopass, + avg_frame_qindex, this_frame_mv_in_out); } arf_boost = (int)boost_score; @@ -2091,14 +2034,14 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, // Cumulative effect of prediction quality decay. if (!flash_detected) { - decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame); + decay_accumulator *= get_prediction_decay_rate(twopass, this_frame); decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR ? MIN_DECAY_FACTOR : decay_accumulator; } - boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame, - avg_frame_qindex, - this_frame_mv_in_out); + boost_score += decay_accumulator * + calc_frame_boost(frame_info, this_frame, twopass, + avg_frame_qindex, this_frame_mv_in_out); } arf_boost += (int)boost_score; @@ -2114,8 +2057,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { TWO_PASS *const twopass = &cpi->twopass; const int avg_inter_frame_qindex = cpi->rc.avg_frame_qindex[INTER_FRAME]; int arf_show_idx = get_show_idx(twopass); - return compute_arf_boost(frame_info, &twopass->first_pass_info, arf_show_idx, - f_frames, b_frames, avg_inter_frame_qindex); + return compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames, + b_frames, avg_inter_frame_qindex); } // Calculate a section intra ratio used in setting max loop filter. @@ -2530,6 +2473,9 @@ typedef struct RANGE { * (The following fields will remain unchanged after initialization of encoder.) * rc->static_scene_max_gf_interval * rc->min_gf_interval + * twopass->sr_diff_factor + * twopass->sr_default_decay_limit + * twopass->zm_factor * * Dynamic fields: * (The following fields will be updated before or after coding each frame.) @@ -2545,9 +2491,10 @@ typedef struct RANGE { */ static int get_gop_coding_frame_num( int *use_alt_ref, const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc, + const TWO_PASS *const twopass, const RATE_CONTROL *rc, int gf_start_show_idx, const RANGE *active_gf_interval, double gop_intra_factor, int lag_in_frames) { + const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; double loop_decay_rate = 1.00; double mv_ratio_accumulator = 0.0; double this_frame_mv_in_out = 0.0; @@ -2588,15 +2535,14 @@ static int get_gop_coding_frame_num( // Monitor for static sections. if ((rc->frames_since_key + gop_coding_frames - 1) > 1) { - zero_motion_accumulator = - VPXMIN(zero_motion_accumulator, - get_zero_motion_factor(frame_info, next_frame)); + zero_motion_accumulator = VPXMIN( + zero_motion_accumulator, get_zero_motion_factor(twopass, next_frame)); } // Accumulate the effect of prediction quality decay. if (!flash_detected) { double last_loop_decay_rate = loop_decay_rate; - loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame); + loop_decay_rate = get_prediction_decay_rate(twopass, next_frame); // Break clause to detect very still sections after motion. For example, // a static image after a fade or other transition. @@ -2656,25 +2602,25 @@ static int get_gop_coding_frame_num( return gop_coding_frames; } -static RANGE get_active_gf_inverval_range( - const FRAME_INFO *frame_info, const RATE_CONTROL *rc, int arf_active_or_kf, - int gf_start_show_idx, int active_worst_quality, int last_boosted_qindex) { +static RANGE get_active_gf_inverval_range_simple(int min_gf_interval, + int arf_active_or_kf, + int frames_to_key) { RANGE active_gf_interval; -#if CONFIG_RATE_CTRL - (void)frame_info; - (void)gf_start_show_idx; - (void)active_worst_quality; - (void)last_boosted_qindex; - active_gf_interval.min = rc->min_gf_interval + arf_active_or_kf + 2; - + active_gf_interval.min = min_gf_interval + arf_active_or_kf + 2; active_gf_interval.max = 16 + arf_active_or_kf; - if ((active_gf_interval.max <= rc->frames_to_key) && - (active_gf_interval.max >= (rc->frames_to_key - rc->min_gf_interval))) { - active_gf_interval.min = rc->frames_to_key / 2; - active_gf_interval.max = rc->frames_to_key / 2; + if ((active_gf_interval.max <= frames_to_key) && + (active_gf_interval.max >= (frames_to_key - min_gf_interval))) { + active_gf_interval.min = frames_to_key / 2; + active_gf_interval.max = frames_to_key / 2; } -#else + return active_gf_interval; +} + +static RANGE get_active_gf_inverval_range( + const FRAME_INFO *frame_info, const RATE_CONTROL *rc, int arf_active_or_kf, + int gf_start_show_idx, int active_worst_quality, int last_boosted_qindex) { + RANGE active_gf_interval; int int_max_q = (int)(vp9_convert_qindex_to_q(active_worst_quality, frame_info->bit_depth)); int q_term = (gf_start_show_idx == 0) @@ -2712,7 +2658,6 @@ static RANGE get_active_gf_inverval_range( } active_gf_interval.max = VPXMAX(active_gf_interval.max, active_gf_interval.min); -#endif return active_gf_interval; } @@ -2773,9 +2718,14 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { vpx_clear_system_state(); - active_gf_interval = get_active_gf_inverval_range( - frame_info, rc, arf_active_or_kf, gf_start_show_idx, - twopass->active_worst_quality, rc->last_boosted_qindex); + if (oxcf->use_simple_encode_api) { + active_gf_interval = get_active_gf_inverval_range_simple( + rc->min_gf_interval, arf_active_or_kf, rc->frames_to_key); + } else { + active_gf_interval = get_active_gf_inverval_range( + frame_info, rc, arf_active_or_kf, gf_start_show_idx, + twopass->active_worst_quality, rc->last_boosted_qindex); + } if (cpi->multi_layer_arf) { int arf_layers = get_arf_layers(cpi->multi_layer_arf, oxcf->enable_auto_arf, @@ -2785,25 +2735,21 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { gop_intra_factor = 1.0; } + gop_coding_frames = get_gop_coding_frame_num( + &use_alt_ref, frame_info, twopass, rc, gf_start_show_idx, + &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); + use_alt_ref &= allow_alt_ref; #if CONFIG_RATE_CTRL - { + // If the external gop_command is on, we will override the decisions + // of gop_coding_frames and use_alt_ref. + if (cpi->oxcf.use_simple_encode_api) { const GOP_COMMAND *gop_command = &cpi->encode_command.gop_command; assert(allow_alt_ref == 1); if (gop_command->use) { gop_coding_frames = gop_command_coding_frame_count(gop_command); use_alt_ref = gop_command->use_alt_ref; - } else { - gop_coding_frames = get_gop_coding_frame_num( - &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx, - &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); - use_alt_ref &= allow_alt_ref; } } -#else - gop_coding_frames = get_gop_coding_frame_num( - &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx, - &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); - use_alt_ref &= allow_alt_ref; #endif // Was the group length constrained by the requirement for a new KF? @@ -2823,8 +2769,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { // Calculate the boost for alt ref. rc->gfu_boost = - compute_arf_boost(frame_info, first_pass_info, arf_show_idx, f_frames, - b_frames, avg_inter_frame_qindex); + compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames, b_frames, + avg_inter_frame_qindex); rc->source_alt_ref_pending = 1; } else { const int f_frames = gop_coding_frames - 1; @@ -2834,9 +2780,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { const int gld_show_idx = VPXMIN(gf_start_show_idx + 1, fps_get_num_frames(first_pass_info)); const int arf_boost = - compute_arf_boost(frame_info, first_pass_info, gld_show_idx, f_frames, - b_frames, avg_inter_frame_qindex); - rc->gfu_boost = VPXMIN(MAX_GF_BOOST, arf_boost); + compute_arf_boost(frame_info, twopass, gld_show_idx, f_frames, b_frames, + avg_inter_frame_qindex); + rc->gfu_boost = VPXMIN((int)twopass->gf_max_total_boost, arf_boost); rc->source_alt_ref_pending = 0; } @@ -2939,7 +2885,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone), group_av_noise, vbr_group_bits_per_frame); twopass->active_worst_quality = - (tmp_q + (twopass->active_worst_quality * 3)) >> 2; + (int)((tmp_q + (twopass->active_worst_quality * + (twopass->active_wq_factor - 1))) / + twopass->active_wq_factor); #if CONFIG_ALWAYS_ADJUST_BPM // Reset rolling actual and target bits counters for ARF groups. @@ -3159,18 +3107,10 @@ static int test_candidate_kf(const FIRST_PASS_INFO *first_pass_info, #define MIN_SCAN_FRAMES_FOR_KF_BOOST 32 #define KF_ABS_ZOOM_THRESH 6.0 -#ifdef AGGRESSIVE_VBR -#define KF_MAX_FRAME_BOOST 80.0 -#define MAX_KF_TOT_BOOST 4800 -#else -#define KF_MAX_FRAME_BOOST 96.0 -#define MAX_KF_TOT_BOOST 5400 -#endif - int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int kf_show_idx, int min_gf_interval) { + const TWO_PASS *const twopass, int kf_show_idx, + int min_gf_interval) { + const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; double recent_loop_decay[FRAMES_TO_CHECK_DECAY]; int j; int frames_to_key; @@ -3197,7 +3137,7 @@ int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, break; // How fast is the prediction quality decaying? - loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame); + loop_decay_rate = get_prediction_decay_rate(twopass, next_frame); // We want to know something about the recent past... rather than // as used elsewhere where we are concerned with decay in prediction @@ -3283,8 +3223,8 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { kf_mod_err = calc_norm_frame_score(oxcf, frame_info, keyframe_stats, mean_mod_score, av_err); - rc->frames_to_key = vp9_get_frames_to_next_key( - oxcf, frame_info, first_pass_info, kf_show_idx, rc->min_gf_interval); + rc->frames_to_key = vp9_get_frames_to_next_key(oxcf, twopass, kf_show_idx, + rc->min_gf_interval); // If there is a max kf interval set by the user we must obey it. // We already breakout of the loop above at 2x max. @@ -3366,7 +3306,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { if (i > 0) { zero_motion_accumulator = VPXMIN(zero_motion_accumulator, - get_zero_motion_factor(&cpi->frame_info, &next_frame)); + get_zero_motion_factor(twopass, &next_frame)); } else { zero_motion_accumulator = next_frame.pcnt_inter - next_frame.pcnt_motion; @@ -3380,8 +3320,8 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { // the first key frame or it points to a refernce before the new key // frame. if (i < 2) sr_accumulator = 0.0; - frame_boost = calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0, - KF_MAX_FRAME_BOOST * zm_factor); + frame_boost = + calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0, zm_factor); boost_score += frame_boost; @@ -3410,12 +3350,12 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { // Special case for static / slide show content but dont apply // if the kf group is very short. if ((zero_motion_accumulator > 0.99) && (rc->frames_to_key > 8)) { - rc->kf_boost = MAX_KF_TOT_BOOST; + rc->kf_boost = (int)(twopass->kf_max_total_boost); } else { - // Apply various clamps for min and max boost + // Apply various clamps for min and max oost rc->kf_boost = VPXMAX((int)boost_score, (rc->frames_to_key * 3)); rc->kf_boost = VPXMAX(rc->kf_boost, MIN_KF_TOT_BOOST); - rc->kf_boost = VPXMIN(rc->kf_boost, MAX_KF_TOT_BOOST); + rc->kf_boost = VPXMIN(rc->kf_boost, (int)(twopass->kf_max_total_boost)); } // Work out how many bits to allocate for the key frame itself. @@ -3451,23 +3391,66 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { } } -static int is_skippable_frame(const VP9_COMP *cpi) { - // If the current frame does not have non-zero motion vector detected in the - // first pass, and so do its previous and forward frames, then this frame - // can be skipped for partition check, and the partition size is assigned - // according to the variance - const TWO_PASS *const twopass = &cpi->twopass; - - return (!frame_is_intra_only(&cpi->common) && - twopass->stats_in - 2 > twopass->stats_in_start && - twopass->stats_in < twopass->stats_in_end && - (twopass->stats_in - 1)->pcnt_inter - - (twopass->stats_in - 1)->pcnt_motion == - 1 && - (twopass->stats_in - 2)->pcnt_inter - - (twopass->stats_in - 2)->pcnt_motion == - 1 && - twopass->stats_in->pcnt_inter - twopass->stats_in->pcnt_motion == 1); +// Configure image size specific vizier parameters. +// Later these will be set via additional command line options +void vp9_init_vizier_params(TWO_PASS *const twopass, int screen_area) { + // When |use_vizier_rc_params| is 1, we expect the rc parameters below to + // have been initialised on the command line as adjustment factors such + // that a factor of 1.0 will match the default behavior when + // |use_vizier_rc_params| is 0 + if (twopass->use_vizier_rc_params) { + twopass->active_wq_factor *= AV_WQ_FACTOR; + twopass->err_per_mb *= BASELINE_ERR_PER_MB; + twopass->sr_default_decay_limit *= DEFAULT_DECAY_LIMIT; + if (twopass->sr_default_decay_limit > 1.0) // > 1.0 here makes no sense + twopass->sr_default_decay_limit = 1.0; + twopass->sr_diff_factor *= 1.0; + twopass->gf_frame_max_boost *= GF_MAX_FRAME_BOOST; + twopass->gf_max_total_boost *= MAX_GF_BOOST; + // NOTE: In use max boost has precedence over min boost. So even if min is + // somehow set higher than max the final boost value will be clamped to the + // appropriate maximum. + twopass->kf_frame_min_boost *= KF_MIN_FRAME_BOOST; + twopass->kf_frame_max_boost_first *= KF_MAX_FRAME_BOOST; + twopass->kf_frame_max_boost_subs *= KF_MAX_FRAME_BOOST; + twopass->kf_max_total_boost *= MAX_KF_TOT_BOOST; + twopass->zm_factor *= DEFAULT_ZM_FACTOR; + if (twopass->zm_factor > 1.0) // > 1.0 here makes no sense + twopass->zm_factor = 1.0; + + // Correction for the fact that the kf_err_per_mb_factor default is + // already different for different video formats and ensures that a passed + // in value of 1.0 on the vizier command line will still match the current + // default. + if (screen_area < 1280 * 720) { + twopass->kf_err_per_mb *= 2000.0; + } else if (screen_area < 1920 * 1080) { + twopass->kf_err_per_mb *= 500.0; + } else { + twopass->kf_err_per_mb *= 250.0; + } + } else { + // When |use_vizier_rc_params| is 0, use defaults. + twopass->active_wq_factor = AV_WQ_FACTOR; + twopass->err_per_mb = BASELINE_ERR_PER_MB; + twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT; + twopass->sr_diff_factor = 1.0; + twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST; + twopass->gf_max_total_boost = MAX_GF_BOOST; + twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST; + twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; + twopass->kf_frame_max_boost_subs = KF_MAX_FRAME_BOOST; + twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; + twopass->zm_factor = DEFAULT_ZM_FACTOR; + + if (screen_area < 1280 * 720) { + twopass->kf_err_per_mb = 2000.0; + } else if (screen_area < 1920 * 1080) { + twopass->kf_err_per_mb = 500.0; + } else { + twopass->kf_err_per_mb = 250.0; + } + } } void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { @@ -3480,6 +3463,13 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { if (!twopass->stats_in) return; + // Configure image size specific vizier parameters + if (cm->current_video_frame == 0) { + unsigned int screen_area = (cm->width * cm->height); + + vp9_init_vizier_params(twopass, screen_area); + } + // If this is an arf frame then we dont want to read the stats file or // advance the input pointer as we already have what we need. if (gf_group->update_type[gf_group->index] == ARF_UPDATE) { @@ -3498,13 +3488,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { cm->frame_type = INTER_FRAME; - // Do the firstpass stats indicate that this frame is skippable for the - // partition search? - if (cpi->sf.allow_partition_search_skip && cpi->oxcf.pass == 2 && - !cpi->use_svc) { - cpi->partition_search_skippable_frame = is_skippable_frame(cpi); - } - // The multiplication by 256 reverses a scaling factor of (>> 8) // applied when combining MB error values for the frame. twopass->mb_av_energy = log((this_frame.intra_error * 256.0) + 1.0); @@ -3587,13 +3570,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { vp9_configure_buffer_updates(cpi, gf_group->index); - // Do the firstpass stats indicate that this frame is skippable for the - // partition search? - if (cpi->sf.allow_partition_search_skip && cpi->oxcf.pass == 2 && - !cpi->use_svc) { - cpi->partition_search_skippable_frame = is_skippable_frame(cpi); - } - rc->base_frame_target = gf_group->bit_allocation[gf_group->index]; // The multiplication by 256 reverses a scaling factor of (>> 8) @@ -3605,9 +3581,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { subtract_stats(&twopass->total_left_stats, &this_frame); } -#define MINQ_ADJ_LIMIT 48 -#define MINQ_ADJ_LIMIT_CQ 20 -#define HIGH_UNDERSHOOT_RATIO 2 void vp9_twopass_postencode_update(VP9_COMP *cpi) { TWO_PASS *const twopass = &cpi->twopass; RATE_CONTROL *const rc = &cpi->rc; @@ -3747,8 +3720,7 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame, *first_is_key_frame = 0; if (rc.frames_to_key == 0) { rc.frames_to_key = vp9_get_frames_to_next_key( - &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info, - *first_show_idx, rc.min_gf_interval); + &cpi->oxcf, &cpi->twopass, *first_show_idx, rc.min_gf_interval); rc.frames_since_key = 0; *first_is_key_frame = 1; } @@ -3756,18 +3728,18 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame, if (gop_command->use) { *coding_frame_count = gop_command_coding_frame_count(gop_command); *use_alt_ref = gop_command->use_alt_ref; - assert(*coding_frame_count < rc.frames_to_key); + assert(gop_command->show_frame_count <= rc.frames_to_key); } else { *coding_frame_count = vp9_get_gop_coding_frame_count( - &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info, &rc, - *first_show_idx, multi_layer_arf, allow_alt_ref, *first_is_key_frame, + &cpi->oxcf, &cpi->twopass, &cpi->frame_info, &rc, *first_show_idx, + multi_layer_arf, allow_alt_ref, *first_is_key_frame, *last_gop_use_alt_ref, use_alt_ref); } } int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf, + const TWO_PASS *const twopass, const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc, int show_idx, int multi_layer_arf, int allow_alt_ref, int first_is_key_frame, @@ -3775,21 +3747,28 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf, int frame_count; double gop_intra_factor; const int arf_active_or_kf = last_gop_use_alt_ref || first_is_key_frame; - RANGE active_gf_interval = get_active_gf_inverval_range( - frame_info, rc, arf_active_or_kf, show_idx, /*active_worst_quality=*/0, - /*last_boosted_qindex=*/0); + RANGE active_gf_interval; + int arf_layers; + if (oxcf->use_simple_encode_api) { + active_gf_interval = get_active_gf_inverval_range_simple( + rc->min_gf_interval, arf_active_or_kf, rc->frames_to_key); + } else { + active_gf_interval = get_active_gf_inverval_range( + frame_info, rc, arf_active_or_kf, show_idx, /*active_worst_quality=*/0, + /*last_boosted_qindex=*/0); + } - const int arf_layers = get_arf_layers(multi_layer_arf, oxcf->enable_auto_arf, - active_gf_interval.max); + arf_layers = get_arf_layers(multi_layer_arf, oxcf->enable_auto_arf, + active_gf_interval.max); if (multi_layer_arf) { gop_intra_factor = 1.0 + 0.25 * arf_layers; } else { gop_intra_factor = 1.0; } - frame_count = get_gop_coding_frame_num( - use_alt_ref, frame_info, first_pass_info, rc, show_idx, - &active_gf_interval, gop_intra_factor, oxcf->lag_in_frames); + frame_count = get_gop_coding_frame_num(use_alt_ref, frame_info, twopass, rc, + show_idx, &active_gf_interval, + gop_intra_factor, oxcf->lag_in_frames); *use_alt_ref &= allow_alt_ref; return frame_count; } @@ -3797,9 +3776,10 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf, // Under CONFIG_RATE_CTRL, once the first_pass_info is ready, the number of // coding frames (including show frame and alt ref) can be determined. int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int multi_layer_arf, int allow_alt_ref) { + const TWO_PASS *const twopass, + const FRAME_INFO *frame_info, int multi_layer_arf, + int allow_alt_ref) { + const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; int coding_frame_num = 0; RATE_CONTROL rc; int gop_coding_frame_count; @@ -3812,14 +3792,14 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, int use_alt_ref; int first_is_key_frame = 0; if (rc.frames_to_key == 0) { - rc.frames_to_key = vp9_get_frames_to_next_key( - oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval); + rc.frames_to_key = vp9_get_frames_to_next_key(oxcf, twopass, show_idx, + rc.min_gf_interval); rc.frames_since_key = 0; first_is_key_frame = 1; } gop_coding_frame_count = vp9_get_gop_coding_frame_count( - oxcf, frame_info, first_pass_info, &rc, show_idx, multi_layer_arf, + oxcf, twopass, frame_info, &rc, show_idx, multi_layer_arf, allow_alt_ref, first_is_key_frame, last_gop_use_alt_ref, &use_alt_ref); rc.source_alt_ref_active = use_alt_ref; @@ -3834,9 +3814,8 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, } void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int *key_frame_map) { + const TWO_PASS *const twopass, int *key_frame_map) { + const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; int show_idx = 0; RATE_CONTROL rc; vp9_rc_init(oxcf, 1, &rc); @@ -3849,8 +3828,8 @@ void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, while (show_idx < first_pass_info->num_frames) { int key_frame_group_size; key_frame_map[show_idx] = 1; - key_frame_group_size = vp9_get_frames_to_next_key( - oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval); + key_frame_group_size = + vp9_get_frames_to_next_key(oxcf, twopass, show_idx, rc.min_gf_interval); assert(key_frame_group_size > 0); show_idx += key_frame_group_size; } diff --git a/third_party/libvpx/vp9/encoder/vp9_firstpass.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h similarity index 86% rename from third_party/libvpx/vp9/encoder/vp9_firstpass.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h index b1047eab2268..cdcf5687234e 100644 --- a/third_party/libvpx/vp9/encoder/vp9_firstpass.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h @@ -21,27 +21,6 @@ extern "C" { #endif -#if CONFIG_FP_MB_STATS - -#define FPMB_DCINTRA_MASK 0x01 - -#define FPMB_MOTION_ZERO_MASK 0x02 -#define FPMB_MOTION_LEFT_MASK 0x04 -#define FPMB_MOTION_RIGHT_MASK 0x08 -#define FPMB_MOTION_UP_MASK 0x10 -#define FPMB_MOTION_DOWN_MASK 0x20 - -#define FPMB_ERROR_SMALL_MASK 0x40 -#define FPMB_ERROR_LARGE_MASK 0x80 -#define FPMB_ERROR_SMALL_TH 2000 -#define FPMB_ERROR_LARGE_TH 48000 - -typedef struct { - uint8_t *mb_stats_start; - uint8_t *mb_stats_end; -} FIRSTPASS_MB_STATS; -#endif - #define INVALID_ROW (-1) #define MAX_ARF_LAYERS 6 @@ -188,12 +167,6 @@ typedef struct { double mb_av_energy; double mb_smooth_pct; -#if CONFIG_FP_MB_STATS - uint8_t *frame_mb_stats_buf; - uint8_t *this_frame_mb_stats; - FIRSTPASS_MB_STATS firstpass_mb_stats; -#endif - FP_MB_FLOAT_STATS *fp_mb_float_stats; // An indication of the content type of the current frame @@ -221,6 +194,24 @@ typedef struct { int last_qindex_of_arf_layer[MAX_ARF_LAYERS]; GF_GROUP gf_group; + + // Vizeir project experimental two pass rate control parameters. + // When |use_vizier_rc_params| is 1, the following parameters will + // be overwritten by pass in values. Otherwise, they are initialized + // by default values. + int use_vizier_rc_params; + double active_wq_factor; + double err_per_mb; + double sr_default_decay_limit; + double sr_diff_factor; + double kf_err_per_mb; + double kf_frame_min_boost; + double kf_frame_max_boost_first; // Max for first kf in a chunk. + double kf_frame_max_boost_subs; // Max for subsequent mid chunk kfs. + double kf_max_total_boost; + double gf_max_total_boost; + double gf_frame_max_boost; + double zm_factor; } TWO_PASS; struct VP9_COMP; @@ -239,6 +230,7 @@ void vp9_first_pass_encode_tile_mb_row(struct VP9_COMP *cpi, void vp9_init_second_pass(struct VP9_COMP *cpi); void vp9_rc_get_second_pass_params(struct VP9_COMP *cpi); +void vp9_init_vizier_params(TWO_PASS *const twopass, int screen_area); // Post encode update of the rate control parameters for 2-pass void vp9_twopass_postencode_update(struct VP9_COMP *cpi); @@ -248,9 +240,8 @@ void calculate_coded_size(struct VP9_COMP *cpi, int *scaled_frame_width, struct VP9EncoderConfig; int vp9_get_frames_to_next_key(const struct VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int kf_show_idx, int min_gf_interval); + const TWO_PASS *const twopass, int kf_show_idx, + int min_gf_interval); #if CONFIG_RATE_CTRL /* Call this function to get info about the next group of pictures. * This function should be called after vp9_create_compressor() when encoding @@ -265,8 +256,8 @@ void vp9_get_next_group_of_picture(const struct VP9_COMP *cpi, /*!\brief Call this function before coding a new group of pictures to get * information about it. * \param[in] oxcf Encoder config + * \param[in] twopass Twopass info * \param[in] frame_info Frame info - * \param[in] first_pass_info First pass stats * \param[in] rc Rate control state * \param[in] show_idx Show index of the first frame in the group * \param[in] multi_layer_arf Is multi-layer alternate reference used @@ -279,27 +270,25 @@ void vp9_get_next_group_of_picture(const struct VP9_COMP *cpi, * \return Returns coding frame count */ int vp9_get_gop_coding_frame_count(const struct VP9EncoderConfig *oxcf, + const TWO_PASS *const twopass, const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc, int show_idx, int multi_layer_arf, int allow_alt_ref, int first_is_key_frame, int last_gop_use_alt_ref, int *use_alt_ref); int vp9_get_coding_frame_num(const struct VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int multi_layer_arf, int allow_alt_ref); + const TWO_PASS *const twopass, + const FRAME_INFO *frame_info, int multi_layer_arf, + int allow_alt_ref); /*!\brief Compute a key frame binary map indicates whether key frames appear * in the corresponding positions. The passed in key_frame_map must point to an - * integer array with length equal to first_pass_info->num_frames, which is the - * number of show frames in the video. + * integer array with length equal to twopass->first_pass_info.num_frames, + * which is the number of show frames in the video. */ void vp9_get_key_frame_map(const struct VP9EncoderConfig *oxcf, - const FRAME_INFO *frame_info, - const FIRST_PASS_INFO *first_pass_info, - int *key_frame_map); + const TWO_PASS *const twopass, int *key_frame_map); #endif // CONFIG_RATE_CTRL FIRSTPASS_STATS vp9_get_frame_stats(const TWO_PASS *twopass); diff --git a/third_party/libvpx/vp9/encoder/vp9_frame_scale.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_frame_scale.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_frame_scale.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_frame_scale.c diff --git a/third_party/libvpx/vp9/encoder/vp9_job_queue.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_job_queue.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h diff --git a/third_party/libvpx/vp9/encoder/vp9_lookahead.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_lookahead.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.c diff --git a/third_party/libvpx/vp9/encoder/vp9_lookahead.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h similarity index 95% rename from third_party/libvpx/vp9/encoder/vp9_lookahead.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h index dbbe3af58401..6ac673667310 100644 --- a/third_party/libvpx/vp9/encoder/vp9_lookahead.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h @@ -82,15 +82,11 @@ int vp9_lookahead_next_show_idx(const struct lookahead_ctx *ctx); * This function will copy the source image into a new framebuffer with * the expected stride/border. * - * If active_map is non-NULL and there is only one frame in the queue, then copy - * only active macroblocks. - * * \param[in] ctx Pointer to the lookahead context * \param[in] src Pointer to the image to enqueue * \param[in] ts_start Timestamp for the start of this frame * \param[in] ts_end Timestamp for the end of this frame * \param[in] flags Flags set on this frame - * \param[in] active_map Map that specifies which macroblock is active */ int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, int64_t ts_start, int64_t ts_end, int use_highbitdepth, diff --git a/third_party/libvpx/vp9/encoder/vp9_mbgraph.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_mbgraph.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.c diff --git a/third_party/libvpx/vp9/encoder/vp9_mbgraph.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_mbgraph.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h diff --git a/third_party/libvpx/vp9/encoder/vp9_mcomp.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_mcomp.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c diff --git a/third_party/libvpx/vp9/encoder/vp9_mcomp.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_mcomp.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h diff --git a/third_party/libvpx/vp9/encoder/vp9_multi_thread.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_multi_thread.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_multi_thread.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_multi_thread.c diff --git a/third_party/libvpx/vp9/encoder/vp9_multi_thread.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_multi_thread.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_multi_thread.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_multi_thread.h diff --git a/third_party/libvpx/vp9/encoder/vp9_noise_estimate.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_noise_estimate.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_noise_estimate.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_noise_estimate.c diff --git a/third_party/libvpx/vp9/encoder/vp9_noise_estimate.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_noise_estimate.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_noise_estimate.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_noise_estimate.h diff --git a/third_party/libvpx/vp9/encoder/vp9_non_greedy_mv.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_non_greedy_mv.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_non_greedy_mv.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_non_greedy_mv.c diff --git a/third_party/libvpx/vp9/encoder/vp9_non_greedy_mv.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_non_greedy_mv.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_non_greedy_mv.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_non_greedy_mv.h diff --git a/third_party/libvpx/vp9/encoder/vp9_partition_models.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_partition_models.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_partition_models.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_partition_models.h diff --git a/third_party/libvpx/vp9/encoder/vp9_picklpf.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_picklpf.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_picklpf.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_picklpf.c diff --git a/third_party/libvpx/vp9/encoder/vp9_picklpf.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_picklpf.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_picklpf.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_picklpf.h diff --git a/third_party/libvpx/vp9/encoder/vp9_pickmode.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_pickmode.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c diff --git a/third_party/libvpx/vp9/encoder/vp9_pickmode.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_pickmode.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.h diff --git a/third_party/libvpx/vp9/encoder/vp9_quantize.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_quantize.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_quantize.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_quantize.c diff --git a/third_party/libvpx/vp9/encoder/vp9_quantize.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_quantize.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_quantize.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_quantize.h diff --git a/third_party/libvpx/vp9/encoder/vp9_ratectrl.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c similarity index 98% rename from third_party/libvpx/vp9/encoder/vp9_ratectrl.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c index 27a529914d6d..e38464c72c99 100644 --- a/third_party/libvpx/vp9/encoder/vp9_ratectrl.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c @@ -39,9 +39,6 @@ #define MAX_MB_RATE 250 #define MAXRATE_1080P 4000000 -#define DEFAULT_KF_BOOST 2000 -#define DEFAULT_GF_BOOST 2000 - #define LIMIT_QRANGE_FOR_ALTREF_AND_KEY 1 #define MIN_BPB_FACTOR 0.005 @@ -280,9 +277,9 @@ static void update_buffer_level_svc_preencode(VP9_COMP *cpi) { svc->current_superframe > 0) { // TODO(marpan): This may need to be modified for temporal layers. const double framerate_pts = 10000000.0 / ts_delta; - lrc->bits_off_target += (int)(lc->target_bandwidth / framerate_pts); + lrc->bits_off_target += (int)round(lc->target_bandwidth / framerate_pts); } else { - lrc->bits_off_target += (int)(lc->target_bandwidth / lc->framerate); + lrc->bits_off_target += (int)round(lc->target_bandwidth / lc->framerate); } // Clip buffer level to maximum buffer size for the layer. lrc->bits_off_target = @@ -410,6 +407,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { rc->source_alt_ref_active = 0; rc->frames_till_gf_update_due = 0; + rc->constrain_gf_key_freq_onepass_vbr = 1; rc->ni_av_qi = oxcf->worst_allowed_q; rc->ni_tot_qi = 0; rc->ni_frames = 0; @@ -441,6 +439,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { rc->last_post_encode_dropped_scene_change = 0; rc->use_post_encode_drop = 0; rc->ext_use_post_encode_drop = 0; + rc->disable_overshoot_maxq_cbr = 0; rc->arf_active_best_quality_adjustment_factor = 1.0; rc->arf_increase_active_best_quality = 0; rc->preserve_arf_as_gld = 0; @@ -1719,10 +1718,12 @@ void vp9_rc_set_frame_target(VP9_COMP *cpi, int target) { } #if CONFIG_RATE_CTRL - if (cpi->encode_command.use_external_target_frame_bits) { - rc->this_frame_target = cpi->encode_command.target_frame_bits; + if (cpi->oxcf.use_simple_encode_api) { + if (cpi->encode_command.use_external_target_frame_bits) { + rc->this_frame_target = cpi->encode_command.target_frame_bits; + } } -#endif +#endif // CONFIG_RATE_CTRL // Target rate per SB64 (including partial SB64s. rc->sb64_target_rate = (int)(((int64_t)rc->this_frame_target * 64 * 64) / @@ -2008,7 +2009,7 @@ void vp9_rc_postencode_update_drop_frame(VP9_COMP *cpi) { } } -static int calc_pframe_target_size_one_pass_vbr(const VP9_COMP *const cpi) { +int vp9_calc_pframe_target_size_one_pass_vbr(const VP9_COMP *cpi) { const RATE_CONTROL *const rc = &cpi->rc; const int af_ratio = rc->af_ratio_onepass_vbr; int64_t target = @@ -2023,7 +2024,7 @@ static int calc_pframe_target_size_one_pass_vbr(const VP9_COMP *const cpi) { return vp9_rc_clamp_pframe_target_size(cpi, (int)target); } -static int calc_iframe_target_size_one_pass_vbr(const VP9_COMP *const cpi) { +int vp9_calc_iframe_target_size_one_pass_vbr(const VP9_COMP *cpi) { static const int kf_ratio = 25; const RATE_CONTROL *rc = &cpi->rc; const int target = rc->avg_frame_bandwidth * kf_ratio; @@ -2049,22 +2050,9 @@ static void adjust_gfint_frame_constraint(VP9_COMP *cpi, int frame_constraint) { } } -void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { - VP9_COMMON *const cm = &cpi->common; +void vp9_set_gf_update_one_pass_vbr(VP9_COMP *const cpi) { RATE_CONTROL *const rc = &cpi->rc; - int target; - if (!cpi->refresh_alt_ref_frame && - (cm->current_video_frame == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY) || - rc->frames_to_key == 0)) { - cm->frame_type = KEY_FRAME; - rc->this_key_frame_forced = - cm->current_video_frame != 0 && rc->frames_to_key == 0; - rc->frames_to_key = cpi->oxcf.key_freq; - rc->kf_boost = DEFAULT_KF_BOOST; - rc->source_alt_ref_active = 0; - } else { - cm->frame_type = INTER_FRAME; - } + VP9_COMMON *const cm = &cpi->common; if (rc->frames_till_gf_update_due == 0) { double rate_err = 1.0; rc->gfu_boost = DEFAULT_GF_BOOST; @@ -2083,18 +2071,23 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { rate_err > 3.5) { rc->baseline_gf_interval = VPXMIN(15, (3 * rc->baseline_gf_interval) >> 1); - } else if (rc->avg_frame_low_motion < 20) { + } else if (rc->avg_frame_low_motion > 0 && + rc->avg_frame_low_motion < 20) { // Decrease gf interval for high motion case. rc->baseline_gf_interval = VPXMAX(6, rc->baseline_gf_interval >> 1); } - // Adjust boost and af_ratio based on avg_frame_low_motion, which varies - // between 0 and 100 (stationary, 100% zero/small motion). - rc->gfu_boost = - VPXMAX(500, DEFAULT_GF_BOOST * (rc->avg_frame_low_motion << 1) / - (rc->avg_frame_low_motion + 100)); + // Adjust boost and af_ratio based on avg_frame_low_motion, which + // varies between 0 and 100 (stationary, 100% zero/small motion). + if (rc->avg_frame_low_motion > 0) + rc->gfu_boost = + VPXMAX(500, DEFAULT_GF_BOOST * (rc->avg_frame_low_motion << 1) / + (rc->avg_frame_low_motion + 100)); + else if (rc->avg_frame_low_motion == 0 && rate_err > 1.0) + rc->gfu_boost = DEFAULT_GF_BOOST >> 1; rc->af_ratio_onepass_vbr = VPXMIN(15, VPXMAX(5, 3 * rc->gfu_boost / 400)); } - adjust_gfint_frame_constraint(cpi, rc->frames_to_key); + if (rc->constrain_gf_key_freq_onepass_vbr) + adjust_gfint_frame_constraint(cpi, rc->frames_to_key); rc->frames_till_gf_update_due = rc->baseline_gf_interval; cpi->refresh_golden_frame = 1; rc->source_alt_ref_pending = 0; @@ -2104,10 +2097,29 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { rc->alt_ref_gf_group = 1; } } +} + +void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { + VP9_COMMON *const cm = &cpi->common; + RATE_CONTROL *const rc = &cpi->rc; + int target; + if (!cpi->refresh_alt_ref_frame && + (cm->current_video_frame == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY) || + rc->frames_to_key == 0)) { + cm->frame_type = KEY_FRAME; + rc->this_key_frame_forced = + cm->current_video_frame != 0 && rc->frames_to_key == 0; + rc->frames_to_key = cpi->oxcf.key_freq; + rc->kf_boost = DEFAULT_KF_BOOST; + rc->source_alt_ref_active = 0; + } else { + cm->frame_type = INTER_FRAME; + } + vp9_set_gf_update_one_pass_vbr(cpi); if (cm->frame_type == KEY_FRAME) - target = calc_iframe_target_size_one_pass_vbr(cpi); + target = vp9_calc_iframe_target_size_one_pass_vbr(cpi); else - target = calc_pframe_target_size_one_pass_vbr(cpi); + target = vp9_calc_pframe_target_size_one_pass_vbr(cpi); vp9_rc_set_frame_target(cpi, target); if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cpi->oxcf.pass == 0) vp9_cyclic_refresh_update_parameters(cpi); @@ -2525,26 +2537,25 @@ void vp9_rc_set_gf_interval_range(const VP9_COMP *const cpi, rc->min_gf_interval = FIXED_GF_INTERVAL; rc->static_scene_max_gf_interval = FIXED_GF_INTERVAL; } else { + double framerate = cpi->framerate; // Set Maximum gf/arf interval rc->max_gf_interval = oxcf->max_gf_interval; rc->min_gf_interval = oxcf->min_gf_interval; #if CONFIG_RATE_CTRL + if (oxcf->use_simple_encode_api) { + // In this experiment, we avoid framerate being changed dynamically during + // encoding. + framerate = oxcf->init_framerate; + } +#endif // CONFIG_RATE_CTRL if (rc->min_gf_interval == 0) { rc->min_gf_interval = vp9_rc_get_default_min_gf_interval( - oxcf->width, oxcf->height, oxcf->init_framerate); + oxcf->width, oxcf->height, framerate); } if (rc->max_gf_interval == 0) { - rc->max_gf_interval = vp9_rc_get_default_max_gf_interval( - oxcf->init_framerate, rc->min_gf_interval); + rc->max_gf_interval = + vp9_rc_get_default_max_gf_interval(framerate, rc->min_gf_interval); } -#else - if (rc->min_gf_interval == 0) - rc->min_gf_interval = vp9_rc_get_default_min_gf_interval( - oxcf->width, oxcf->height, cpi->framerate); - if (rc->max_gf_interval == 0) - rc->max_gf_interval = vp9_rc_get_default_max_gf_interval( - cpi->framerate, rc->min_gf_interval); -#endif // Extended max interval for genuinely static scenes like slide shows. rc->static_scene_max_gf_interval = MAX_STATIC_GF_GROUP_LENGTH; @@ -2704,18 +2715,18 @@ int vp9_resize_one_pass_cbr(VP9_COMP *cpi) { // Force downsize based on per-frame-bandwidth, for extreme case, // for HD input. if (cpi->resize_state == ORIG && cm->width * cm->height >= 1280 * 720) { - if (rc->avg_frame_bandwidth < (int)(300000 / 30)) { + if (rc->avg_frame_bandwidth < 300000 / 30) { resize_action = DOWN_ONEHALF; cpi->resize_state = ONE_HALF; force_downsize_rate = 1; - } else if (rc->avg_frame_bandwidth < (int)(400000 / 30)) { + } else if (rc->avg_frame_bandwidth < 400000 / 30) { resize_action = ONEHALFONLY_RESIZE ? DOWN_ONEHALF : DOWN_THREEFOUR; cpi->resize_state = ONEHALFONLY_RESIZE ? ONE_HALF : THREE_QUARTER; force_downsize_rate = 1; } } else if (cpi->resize_state == THREE_QUARTER && cm->width * cm->height >= 960 * 540) { - if (rc->avg_frame_bandwidth < (int)(300000 / 30)) { + if (rc->avg_frame_bandwidth < 300000 / 30) { resize_action = DOWN_ONEHALF; cpi->resize_state = ONE_HALF; force_downsize_rate = 1; @@ -2952,7 +2963,7 @@ static void adjust_gf_boost_lag_one_pass_vbr(VP9_COMP *cpi, } } } - target = calc_pframe_target_size_one_pass_vbr(cpi); + target = vp9_calc_pframe_target_size_one_pass_vbr(cpi); vp9_rc_set_frame_target(cpi, target); } rc->prev_avg_source_sad_lag = avg_source_sad_lag; @@ -3162,7 +3173,7 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) { VPXMIN(20, VPXMAX(10, rc->baseline_gf_interval)); adjust_gfint_frame_constraint(cpi, rc->frames_to_key); rc->frames_till_gf_update_due = rc->baseline_gf_interval; - target = calc_pframe_target_size_one_pass_vbr(cpi); + target = vp9_calc_pframe_target_size_one_pass_vbr(cpi); vp9_rc_set_frame_target(cpi, target); rc->count_last_scene_change = 0; } else { diff --git a/third_party/libvpx/vp9/encoder/vp9_ratectrl.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h similarity index 95% rename from third_party/libvpx/vp9/encoder/vp9_ratectrl.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h index c5ffb153c8c2..83a12cde730d 100644 --- a/third_party/libvpx/vp9/encoder/vp9_ratectrl.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h @@ -27,6 +27,9 @@ extern "C" { // Bits Per MB at different Q (Multiplied by 512) #define BPER_MB_NORMBITS 9 +#define DEFAULT_KF_BOOST 2000 +#define DEFAULT_GF_BOOST 2000 + #define MIN_GF_INTERVAL 4 #define MAX_GF_INTERVAL 16 #define FIXED_GF_INTERVAL 8 // Used in some testing modes only @@ -195,7 +198,8 @@ typedef struct { int use_post_encode_drop; // External flag to enable post encode frame dropping, controlled by user. int ext_use_post_encode_drop; - + // Flag to disable CBR feature to increase Q on overshoot detection. + int disable_overshoot_maxq_cbr; int damped_adjustment[RATE_FACTOR_LEVELS]; double arf_active_best_quality_adjustment_factor; int arf_increase_active_best_quality; @@ -203,6 +207,10 @@ typedef struct { int preserve_arf_as_gld; int preserve_next_arf_as_gld; int show_arf_as_gld; + + // Flag to constrain golden frame interval on key frame frequency for 1 pass + // VBR. + int constrain_gf_key_freq_onepass_vbr; } RATE_CONTROL; struct VP9_COMP; @@ -254,6 +262,9 @@ void vp9_rc_get_one_pass_vbr_params(struct VP9_COMP *cpi); void vp9_rc_get_one_pass_cbr_params(struct VP9_COMP *cpi); int vp9_calc_pframe_target_size_one_pass_cbr(const struct VP9_COMP *cpi); int vp9_calc_iframe_target_size_one_pass_cbr(const struct VP9_COMP *cpi); +int vp9_calc_pframe_target_size_one_pass_vbr(const struct VP9_COMP *cpi); +int vp9_calc_iframe_target_size_one_pass_vbr(const struct VP9_COMP *cpi); +void vp9_set_gf_update_one_pass_vbr(struct VP9_COMP *const cpi); void vp9_update_buffer_level_preencode(struct VP9_COMP *cpi); void vp9_rc_get_svc_params(struct VP9_COMP *cpi); diff --git a/third_party/libvpx/vp9/encoder/vp9_rd.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c similarity index 92% rename from third_party/libvpx/vp9/encoder/vp9_rd.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c index 34c74424ce0e..9fa3ff186509 100644 --- a/third_party/libvpx/vp9/encoder/vp9_rd.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c @@ -197,28 +197,68 @@ static const int rd_boost_factor[16] = { 64, 32, 32, 32, 24, 16, 12, 12, static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = { 128, 144, 128, 128, 144, 144 }; +// Configure Vizier RD parameters. +// Later this function will use passed in command line values. +void vp9_init_rd_parameters(VP9_COMP *cpi) { + RD_CONTROL *const rdc = &cpi->rd_ctrl; + + // When |use_vizier_rc_params| is 1, we expect the rd parameters have been + // initialized by the pass in values. + // Be careful that parameters below are only initialized to 1, if we do not + // pass values to them. It is desired to take care of each parameter when + // using |use_vizier_rc_params|. + if (cpi->twopass.use_vizier_rc_params) return; + + // Make sure this function is floating point safe. + vpx_clear_system_state(); + + rdc->rd_mult_inter_qp_fac = 1.0; + rdc->rd_mult_arf_qp_fac = 1.0; + rdc->rd_mult_key_qp_fac = 1.0; +} + +// Returns the default rd multiplier for inter frames for a given qindex. +// The function here is a first pass estimate based on data from +// a previous Vizer run +static double def_inter_rd_multiplier(int qindex) { + return 4.15 + (0.001 * (double)qindex); +} + +// Returns the default rd multiplier for ARF/Golden Frames for a given qindex. +// The function here is a first pass estimate based on data from +// a previous Vizer run +static double def_arf_rd_multiplier(int qindex) { + return 4.25 + (0.001 * (double)qindex); +} + +// Returns the default rd multiplier for key frames for a given qindex. +// The function here is a first pass estimate based on data from +// a previous Vizer run +static double def_kf_rd_multiplier(int qindex) { + return 4.35 + (0.001 * (double)qindex); +} + int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) { - // largest dc_quant is 21387, therefore rdmult should always fit in int32_t + const RD_CONTROL *rdc = &cpi->rd_ctrl; const int q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth); - uint32_t rdmult = q * q; - - if (cpi->common.frame_type != KEY_FRAME) { - if (qindex < 128) - rdmult = rdmult * 4; - else if (qindex < 190) - rdmult = rdmult * 4 + rdmult / 2; - else - rdmult = rdmult * 3; + // largest dc_quant is 21387, therefore rdmult should fit in int32_t + int rdmult = q * q; + + // Make sure this function is floating point safe. + vpx_clear_system_state(); + + if (cpi->common.frame_type == KEY_FRAME) { + double def_rd_q_mult = def_kf_rd_multiplier(qindex); + rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_key_qp_fac); + } else if (!cpi->rc.is_src_frame_alt_ref && + (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { + double def_rd_q_mult = def_arf_rd_multiplier(qindex); + rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_arf_qp_fac); } else { - if (qindex < 64) - rdmult = rdmult * 4; - else if (qindex <= 128) - rdmult = rdmult * 3 + rdmult / 2; - else if (qindex < 190) - rdmult = rdmult * 4 + rdmult / 2; - else - rdmult = rdmult * 7 + rdmult / 2; + double def_rd_q_mult = def_inter_rd_multiplier(qindex); + rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_inter_qp_fac); } + #if CONFIG_VP9_HIGHBITDEPTH switch (cpi->common.bit_depth) { case VPX_BITS_10: rdmult = ROUND_POWER_OF_TWO(rdmult, 4); break; diff --git a/third_party/libvpx/vp9/encoder/vp9_rd.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h similarity index 96% rename from third_party/libvpx/vp9/encoder/vp9_rd.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h index 4c04c9548235..d2bc5e60ed48 100644 --- a/third_party/libvpx/vp9/encoder/vp9_rd.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h @@ -101,6 +101,13 @@ typedef enum { THR_INTRA, } THR_MODES_SUB8X8; +typedef struct { + // RD multiplier control factors added for Vizier project. + double rd_mult_inter_qp_fac; + double rd_mult_arf_qp_fac; + double rd_mult_key_qp_fac; +} RD_CONTROL; + typedef struct RD_OPT { // Thresh_mult is used to set a threshold for the rd score. A higher value // means that we will accept the best mode so far more often. This number @@ -144,6 +151,8 @@ struct TileDataEnc; struct VP9_COMP; struct macroblock; +void vp9_init_rd_parameters(struct VP9_COMP *cpi); + int vp9_compute_rd_mult_based_on_qindex(const struct VP9_COMP *cpi, int qindex); int vp9_compute_rd_mult(const struct VP9_COMP *cpi, int qindex); diff --git a/third_party/libvpx/vp9/encoder/vp9_rdopt.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c similarity index 99% rename from third_party/libvpx/vp9/encoder/vp9_rdopt.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c index 37de4e483996..a1687dcf4614 100644 --- a/third_party/libvpx/vp9/encoder/vp9_rdopt.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c @@ -745,8 +745,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, MODE_INFO *const mi = xd->mi[0]; int64_t rd1, rd2, rd; int rate; - int64_t dist; - int64_t sse; + int64_t dist = INT64_MAX; + int64_t sse = INT64_MAX; const int coeff_ctx = combine_entropy_contexts(args->t_left[blk_row], args->t_above[blk_col]); struct buf_2d *recon = args->this_recon; @@ -799,6 +799,13 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, if (max_txsize_lookup[plane_bsize] == tx_size) skip_txfm_flag = x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))]; + // This reduces the risk of bad perceptual quality due to bad prediction. + // We always force the encoder to perform transform and quantization. + if (!args->cpi->sf.allow_skip_txfm_ac_dc && + skip_txfm_flag == SKIP_TXFM_AC_DC) { + skip_txfm_flag = SKIP_TXFM_NONE; + } + if (skip_txfm_flag == SKIP_TXFM_NONE || (recon && skip_txfm_flag == SKIP_TXFM_AC_ONLY)) { // full forward transform and quantization @@ -827,17 +834,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, dist = VPXMAX(0, sse - dc_correct); } } else { - // SKIP_TXFM_AC_DC - // skip forward transform. Because this is handled here, the quantization - // does not need to do it. - x->plane[plane].eobs[block] = 0; - sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; - dist = sse; - if (recon) { - uint8_t *rec_ptr = &recon->buf[4 * (blk_row * recon->stride + blk_col)]; - copy_block_visible(xd, pd, dst, dst_stride, rec_ptr, recon->stride, - blk_row, blk_col, plane_bsize, tx_bsize); - } + assert(0 && "allow_skip_txfm_ac_dc does not allow SKIP_TXFM_AC_DC."); } } diff --git a/third_party/libvpx/vp9/encoder/vp9_rdopt.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_rdopt.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h diff --git a/third_party/libvpx/vp9/encoder/vp9_resize.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_resize.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_resize.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_resize.c diff --git a/third_party/libvpx/vp9/encoder/vp9_resize.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_resize.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_resize.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_resize.h diff --git a/third_party/libvpx/vp9/encoder/vp9_segmentation.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_segmentation.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_segmentation.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_segmentation.c diff --git a/third_party/libvpx/vp9/encoder/vp9_segmentation.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_segmentation.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_segmentation.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_segmentation.h diff --git a/third_party/libvpx/vp9/encoder/vp9_skin_detection.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_skin_detection.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_skin_detection.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_skin_detection.c diff --git a/third_party/libvpx/vp9/encoder/vp9_skin_detection.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_skin_detection.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_skin_detection.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_skin_detection.h diff --git a/third_party/libvpx/vp9/encoder/vp9_speed_features.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c similarity index 99% rename from third_party/libvpx/vp9/encoder/vp9_speed_features.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c index 5bbe54923689..81695e9156d5 100644 --- a/third_party/libvpx/vp9/encoder/vp9_speed_features.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c @@ -345,7 +345,6 @@ static void set_good_speed_feature_framesize_independent(VP9_COMP *cpi, sf->intra_y_mode_mask[TX_32X32] = INTRA_DC; sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC; sf->adaptive_interp_filter_search = 1; - sf->allow_partition_search_skip = 1; if (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) { for (i = 0; i < MAX_MESH_STEP; ++i) { @@ -621,7 +620,7 @@ static void set_rt_speed_feature_framesize_independent( // increase in encoding time. if (cpi->use_svc && svc->spatial_layer_id > 0) sf->nonrd_keyframe = 1; if (cm->frame_type != KEY_FRAME && cpi->resize_state == ORIG && - cpi->oxcf.rc_mode == VPX_CBR) { + cpi->oxcf.rc_mode == VPX_CBR && !cpi->rc.disable_overshoot_maxq_cbr) { if (cm->width * cm->height <= 352 * 288 && !cpi->use_svc && cpi->oxcf.content != VP9E_CONTENT_SCREEN) sf->overshoot_detection_cbr_rt = RE_ENCODE_MAXQ; @@ -668,7 +667,7 @@ static void set_rt_speed_feature_framesize_independent( sf->base_mv_aggressive = 1; } if (cm->frame_type != KEY_FRAME && cpi->resize_state == ORIG && - cpi->oxcf.rc_mode == VPX_CBR) + cpi->oxcf.rc_mode == VPX_CBR && !cpi->rc.disable_overshoot_maxq_cbr) sf->overshoot_detection_cbr_rt = FAST_DETECTION_MAXQ; } @@ -931,7 +930,6 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) { sf->max_delta_qindex = 0; sf->disable_filter_search_var_thresh = 0; sf->adaptive_interp_filter_search = 0; - sf->allow_partition_search_skip = 0; sf->allow_txfm_domain_distortion = 0; sf->tx_domain_thresh = 99.0; sf->allow_quant_coeff_opt = sf->optimize_coefficients; @@ -940,6 +938,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) { sf->enable_tpl_model = oxcf->enable_tpl_model; sf->prune_ref_frame_for_rect_partitions = 0; sf->temporal_filter_search_method = MESH; + sf->allow_skip_txfm_ac_dc = 0; for (i = 0; i < TX_SIZES; i++) { sf->intra_y_mode_mask[i] = INTRA_ALL; diff --git a/third_party/libvpx/vp9/encoder/vp9_speed_features.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h similarity index 98% rename from third_party/libvpx/vp9/encoder/vp9_speed_features.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h index ca284ded821c..c2ae970b7784 100644 --- a/third_party/libvpx/vp9/encoder/vp9_speed_features.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h @@ -525,9 +525,6 @@ typedef struct SPEED_FEATURES { int prune_rect_thresh[4]; } rd_ml_partition; - // Allow skipping partition search for still image frame - int allow_partition_search_skip; - // Fast approximation of vp9_model_rd_from_var_lapndz int simple_model_rd_from_var; @@ -612,6 +609,12 @@ typedef struct SPEED_FEATURES { // For real-time mode: force DC only under intra search when content // does not have high souce SAD. int rt_intra_dc_only_low_content; + + // The encoder has a feature that skips forward transform and quantization + // based on a model rd estimation to reduce encoding time. + // However, this feature is dangerous since it could lead to bad perceptual + // quality. This flag is added to guard the feature. + int allow_skip_txfm_ac_dc; } SPEED_FEATURES; struct VP9_COMP; diff --git a/third_party/libvpx/vp9/encoder/vp9_subexp.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_subexp.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_subexp.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_subexp.c diff --git a/third_party/libvpx/vp9/encoder/vp9_subexp.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_subexp.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_subexp.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_subexp.h diff --git a/third_party/libvpx/vp9/encoder/vp9_svc_layercontext.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.c similarity index 99% rename from third_party/libvpx/vp9/encoder/vp9_svc_layercontext.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.c index d85b3632cd59..ad3a8f7afac5 100644 --- a/third_party/libvpx/vp9/encoder/vp9_svc_layercontext.c +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.c @@ -322,8 +322,8 @@ void vp9_update_temporal_layer_framerate(VP9_COMP *const cpi) { const int prev_layer_target_bandwidth = oxcf->layer_target_bitrate[st_idx - 1]; lc->avg_frame_size = - (int)((lc->target_bandwidth - prev_layer_target_bandwidth) / - (lc->framerate - prev_layer_framerate)); + (int)round((lc->target_bandwidth - prev_layer_target_bandwidth) / + (lc->framerate - prev_layer_framerate)); } } @@ -357,6 +357,7 @@ void vp9_restore_layer_context(VP9_COMP *const cpi) { if (is_one_pass_cbr_svc(cpi) && lc->speed > 0) { cpi->oxcf.speed = lc->speed; } + cpi->loopfilter_ctrl = lc->loopfilter_ctrl; // Reset the frames_since_key and frames_to_key counters to their values // before the layer restore. Keep these defined for the stream (not layer). if (cpi->svc.number_temporal_layers > 1 || @@ -955,7 +956,7 @@ int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) { if (cpi->common.frame_type != KEY_FRAME && !cpi->ext_refresh_last_frame && !cpi->ext_refresh_golden_frame && !cpi->ext_refresh_alt_ref_frame) svc->non_reference_frame = 1; - // For non-flexible mode, where update_buffer_slot is used, need to check if + // For flexible mode, where update_buffer_slot is used, need to check if // all buffer slots are not refreshed. if (svc->temporal_layering_mode == VP9E_TEMPORAL_LAYERING_MODE_BYPASS) { if (svc->update_buffer_slot[svc->spatial_layer_id] != 0) diff --git a/third_party/libvpx/vp9/encoder/vp9_svc_layercontext.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.h similarity index 98% rename from third_party/libvpx/vp9/encoder/vp9_svc_layercontext.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.h index e7d9712aae25..b2d1d1b98fd7 100644 --- a/third_party/libvpx/vp9/encoder/vp9_svc_layercontext.h +++ b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.h @@ -71,6 +71,7 @@ typedef struct { int actual_num_seg2_blocks; int counter_encode_maxq_scene_change; uint8_t speed; + int loopfilter_ctrl; } LAYER_CONTEXT; typedef struct SVC { @@ -172,6 +173,8 @@ typedef struct SVC { uint8_t fb_idx_temporal_layer_id[REF_FRAMES]; int spatial_layer_sync[VPX_SS_MAX_LAYERS]; + // Quantizer for each spatial layer. + int base_qindex[VPX_SS_MAX_LAYERS]; uint8_t set_intra_only_frame; uint8_t previous_frame_is_intra_only; uint8_t superframe_has_layer_sync; diff --git a/third_party/libvpx/vp9/encoder/vp9_temporal_filter.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_temporal_filter.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_temporal_filter.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_temporal_filter.c diff --git a/third_party/libvpx/vp9/encoder/vp9_temporal_filter.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_temporal_filter.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_temporal_filter.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_temporal_filter.h diff --git a/third_party/libvpx/vp9/encoder/vp9_tokenize.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_tokenize.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_tokenize.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_tokenize.c diff --git a/third_party/libvpx/vp9/encoder/vp9_tokenize.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_tokenize.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_tokenize.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_tokenize.h diff --git a/third_party/libvpx/vp9/encoder/vp9_treewriter.c b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_treewriter.c similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_treewriter.c rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_treewriter.c diff --git a/third_party/libvpx/vp9/encoder/vp9_treewriter.h b/third_party/libvpx/source/libvpx/vp9/encoder/vp9_treewriter.h similarity index 100% rename from third_party/libvpx/vp9/encoder/vp9_treewriter.h rename to third_party/libvpx/source/libvpx/vp9/encoder/vp9_treewriter.h diff --git a/third_party/libvpx/vp9/encoder/x86/highbd_temporal_filter_sse4.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/highbd_temporal_filter_sse4.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/highbd_temporal_filter_sse4.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/highbd_temporal_filter_sse4.c diff --git a/third_party/libvpx/vp9/encoder/x86/temporal_filter_constants.h b/third_party/libvpx/source/libvpx/vp9/encoder/x86/temporal_filter_constants.h similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/temporal_filter_constants.h rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/temporal_filter_constants.h diff --git a/third_party/libvpx/vp9/encoder/x86/temporal_filter_sse4.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/temporal_filter_sse4.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/temporal_filter_sse4.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/temporal_filter_sse4.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_dct_intrin_sse2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_dct_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_dct_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_dct_intrin_sse2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_dct_sse2.asm b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_dct_sse2.asm similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_dct_sse2.asm rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_dct_sse2.asm diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_denoiser_sse2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_denoiser_sse2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_denoiser_sse2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_denoiser_sse2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_error_avx2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_avx2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_error_avx2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_avx2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_error_sse2.asm b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_sse2.asm similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_error_sse2.asm rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_sse2.asm diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_frame_scale_ssse3.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_frame_scale_ssse3.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_frame_scale_ssse3.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_frame_scale_ssse3.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_highbd_block_error_intrin_sse2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_highbd_block_error_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_highbd_block_error_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_highbd_block_error_intrin_sse2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_quantize_sse2.c b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_sse2.c similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_quantize_sse2.c rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_sse2.c diff --git a/third_party/libvpx/vp9/encoder/x86/vp9_quantize_ssse3_x86_64.asm b/third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_ssse3_x86_64.asm similarity index 100% rename from third_party/libvpx/vp9/encoder/x86/vp9_quantize_ssse3_x86_64.asm rename to third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_ssse3_x86_64.asm diff --git a/third_party/libvpx/vp9/exports_dec b/third_party/libvpx/source/libvpx/vp9/exports_dec similarity index 100% rename from third_party/libvpx/vp9/exports_dec rename to third_party/libvpx/source/libvpx/vp9/exports_dec diff --git a/third_party/libvpx/vp9/exports_enc b/third_party/libvpx/source/libvpx/vp9/exports_enc similarity index 100% rename from third_party/libvpx/vp9/exports_enc rename to third_party/libvpx/source/libvpx/vp9/exports_enc diff --git a/third_party/libvpx/vp9/ratectrl_rtc.cc b/third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.cc similarity index 75% rename from third_party/libvpx/vp9/ratectrl_rtc.cc rename to third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.cc index 47f9f3ba33ee..76ff367c0693 100644 --- a/third_party/libvpx/vp9/ratectrl_rtc.cc +++ b/third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.cc @@ -11,6 +11,7 @@ #include +#include "vp9/common/vp9_common.h" #include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_picklpf.h" #include "vpx/vp8cx.h" @@ -24,10 +25,19 @@ std::unique_ptr VP9RateControlRTC::Create( VP9RateControlRTC()); if (!rc_api) return nullptr; rc_api->cpi_ = static_cast(vpx_memalign(32, sizeof(*cpi_))); - if (rc_api->cpi_ == nullptr) { - return nullptr; - } + if (!rc_api->cpi_) return nullptr; + vp9_zero(*rc_api->cpi_); + rc_api->InitRateControl(cfg); + if (cfg.aq_mode) { + VP9_COMP *const cpi = rc_api->cpi_; + cpi->segmentation_map = static_cast( + vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, + sizeof(*cpi->segmentation_map))); + cpi->cyclic_refresh = + vp9_cyclic_refresh_alloc(cpi->common.mi_rows, cpi->common.mi_cols); + cpi->cyclic_refresh->content_mode = 0; + } return rc_api; } @@ -38,13 +48,18 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { cm->profile = PROFILE_0; cm->bit_depth = VPX_BITS_8; cm->show_frame = 1; - oxcf->rc_mode = VPX_CBR; + oxcf->profile = cm->profile; + oxcf->bit_depth = cm->bit_depth; + oxcf->rc_mode = rc_cfg.rc_mode; oxcf->pass = 0; - oxcf->aq_mode = NO_AQ; + oxcf->aq_mode = rc_cfg.aq_mode ? CYCLIC_REFRESH_AQ : NO_AQ; oxcf->content = VP9E_CONTENT_DEFAULT; oxcf->drop_frames_water_mark = 0; + cm->current_video_frame = 0; + rc->kf_boost = DEFAULT_KF_BOOST; UpdateRateControl(rc_cfg); + vp9_set_mb_mi(cm, cm->width, cm->height); cpi_->use_svc = (cpi_->svc.number_spatial_layers > 1 || cpi_->svc.number_temporal_layers > 1) @@ -55,8 +70,8 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { rc->rc_2_frame = 0; vp9_rc_init_minq_luts(); vp9_rc_init(oxcf, 0, rc); + rc->constrain_gf_key_freq_onepass_vbr = 0; cpi_->sf.use_nonrd_pick_mode = 1; - cm->current_video_frame = 0; } void VP9RateControlRTC::UpdateRateControl( @@ -73,6 +88,7 @@ void VP9RateControlRTC::UpdateRateControl( oxcf->best_allowed_q = vp9_quantizer_to_qindex(rc_cfg.min_quantizer); rc->worst_quality = oxcf->worst_allowed_q; rc->best_quality = oxcf->best_allowed_q; + oxcf->init_framerate = rc_cfg.framerate; oxcf->target_bandwidth = 1000 * rc_cfg.target_bandwidth; oxcf->starting_buffer_level_ms = rc_cfg.buf_initial_sz; oxcf->optimal_buffer_level_ms = rc_cfg.buf_optimal_sz; @@ -85,10 +101,11 @@ void VP9RateControlRTC::UpdateRateControl( (rc_cfg.ts_number_layers > 1) ? rc_cfg.ts_number_layers : 0); cpi_->oxcf.rc_max_intra_bitrate_pct = rc_cfg.max_intra_bitrate_pct; + cpi_->oxcf.rc_max_inter_bitrate_pct = rc_cfg.max_inter_bitrate_pct; cpi_->framerate = rc_cfg.framerate; cpi_->svc.number_spatial_layers = rc_cfg.ss_number_layers; cpi_->svc.number_temporal_layers = rc_cfg.ts_number_layers; - + vp9_set_mb_mi(cm, cm->width, cm->height); for (int sl = 0; sl < cpi_->svc.number_spatial_layers; ++sl) { for (int tl = 0; tl < cpi_->svc.number_temporal_layers; ++tl) { const int layer = @@ -138,11 +155,27 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { cpi_->sf.use_nonrd_pick_mode = 1; if (cpi_->svc.number_spatial_layers == 1 && cpi_->svc.number_temporal_layers == 1) { - int target; - if (frame_is_intra_only(cm)) - target = vp9_calc_iframe_target_size_one_pass_cbr(cpi_); - else - target = vp9_calc_pframe_target_size_one_pass_cbr(cpi_); + int target = 0; + if (cpi_->oxcf.rc_mode == VPX_CBR) { + if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + vp9_cyclic_refresh_update_parameters(cpi_); + if (frame_is_intra_only(cm)) + target = vp9_calc_iframe_target_size_one_pass_cbr(cpi_); + else + target = vp9_calc_pframe_target_size_one_pass_cbr(cpi_); + } else if (cpi_->oxcf.rc_mode == VPX_VBR) { + if (cm->frame_type == KEY_FRAME) { + cpi_->rc.this_key_frame_forced = cm->current_video_frame != 0; + cpi_->rc.frames_to_key = cpi_->oxcf.key_freq; + } + vp9_set_gf_update_one_pass_vbr(cpi_); + if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + vp9_cyclic_refresh_update_parameters(cpi_); + if (frame_is_intra_only(cm)) + target = vp9_calc_iframe_target_size_one_pass_vbr(cpi_); + else + target = vp9_calc_pframe_target_size_one_pass_vbr(cpi_); + } vp9_rc_set_frame_target(cpi_, target); vp9_update_buffer_level_preencode(cpi_); } else { @@ -153,6 +186,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { int bottom_index, top_index; cpi_->common.base_qindex = vp9_rc_pick_q_and_bounds(cpi_, &bottom_index, &top_index); + + if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) vp9_cyclic_refresh_setup(cpi_); } int VP9RateControlRTC::GetQP() const { return cpi_->common.base_qindex; } @@ -163,6 +198,14 @@ int VP9RateControlRTC::GetLoopfilterLevel() const { return lf->filter_level; } +signed char *VP9RateControlRTC::GetCyclicRefreshMap() const { + return cpi_->cyclic_refresh->map; +} + +int *VP9RateControlRTC::GetDeltaQ() const { + return cpi_->cyclic_refresh->qindex_delta; +} + void VP9RateControlRTC::PostEncodeUpdate(uint64_t encoded_frame_size) { vp9_rc_postencode_update(cpi_, encoded_frame_size); if (cpi_->svc.number_spatial_layers > 1 || diff --git a/third_party/libvpx/vp9/ratectrl_rtc.h b/third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.h similarity index 66% rename from third_party/libvpx/vp9/ratectrl_rtc.h rename to third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.h index 72ea40fd68bc..d2b9417aefa0 100644 --- a/third_party/libvpx/vp9/ratectrl_rtc.h +++ b/third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.h @@ -18,27 +18,30 @@ #include "vp9/common/vp9_enums.h" #include "vp9/common/vp9_onyxc_int.h" #include "vp9/vp9_iface_common.h" +#include "vp9/encoder/vp9_aq_cyclicrefresh.h" #include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/vp9_cx_iface.h" +#include "vpx/internal/vpx_ratectrl_rtc.h" #include "vpx_mem/vpx_mem.h" namespace libvpx { -struct VP9RateControlRtcConfig { - int width; - int height; - // 0-63 - int max_quantizer; - int min_quantizer; - int64_t target_bandwidth; - int64_t buf_initial_sz; - int64_t buf_optimal_sz; - int64_t buf_sz; - int undershoot_pct; - int overshoot_pct; - int max_intra_bitrate_pct; - double framerate; +struct VP9RateControlRtcConfig : public VpxRateControlRtcConfig { + public: + VP9RateControlRtcConfig() { + vp9_zero(max_quantizers); + vp9_zero(min_quantizers); + vp9_zero(scaling_factor_den); + vp9_zero(scaling_factor_num); + vp9_zero(layer_target_bitrate); + vp9_zero(ts_rate_decimator); + scaling_factor_num[0] = 1; + scaling_factor_den[0] = 1; + max_quantizers[0] = max_quantizer; + min_quantizers[0] = min_quantizer; + } + // Number of spatial layers int ss_number_layers; // Number of temporal layers @@ -47,8 +50,6 @@ struct VP9RateControlRtcConfig { int min_quantizers[VPX_MAX_LAYERS]; int scaling_factor_num[VPX_SS_MAX_LAYERS]; int scaling_factor_den[VPX_SS_MAX_LAYERS]; - int layer_target_bitrate[VPX_MAX_LAYERS]; - int ts_rate_decimator[VPX_TS_MAX_LAYERS]; }; struct VP9FrameParamsQpRTC { @@ -58,7 +59,7 @@ struct VP9FrameParamsQpRTC { }; // This interface allows using VP9 real-time rate control without initializing -// the encoder. To use this interface, you need to link with libvp9rc.a. +// the encoder. To use this interface, you need to link with libvpxrc.a. // // #include "vp9/ratectrl_rtc.h" // VP9RateControlRTC rc_api; @@ -84,15 +85,23 @@ class VP9RateControlRTC { const VP9RateControlRtcConfig &cfg); ~VP9RateControlRTC() { if (cpi_) { - for (int sl = 0; sl < cpi_->svc.number_spatial_layers; sl++) { - for (int tl = 0; tl < cpi_->svc.number_temporal_layers; tl++) { - int layer = LAYER_IDS_TO_IDX(sl, tl, cpi_->oxcf.ts_number_layers); - LAYER_CONTEXT *const lc = &cpi_->svc.layer_context[layer]; - vpx_free(lc->map); - vpx_free(lc->last_coded_q_map); - vpx_free(lc->consec_zero_mv); + if (cpi_->svc.number_spatial_layers > 1 || + cpi_->svc.number_temporal_layers > 1) { + for (int sl = 0; sl < cpi_->svc.number_spatial_layers; sl++) { + for (int tl = 0; tl < cpi_->svc.number_temporal_layers; tl++) { + int layer = LAYER_IDS_TO_IDX(sl, tl, cpi_->oxcf.ts_number_layers); + LAYER_CONTEXT *const lc = &cpi_->svc.layer_context[layer]; + vpx_free(lc->map); + vpx_free(lc->last_coded_q_map); + vpx_free(lc->consec_zero_mv); + } } } + if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { + vpx_free(cpi_->segmentation_map); + cpi_->segmentation_map = NULL; + vp9_cyclic_refresh_free(cpi_->cyclic_refresh); + } vpx_free(cpi_); } } @@ -101,6 +110,8 @@ class VP9RateControlRTC { // GetQP() needs to be called after ComputeQP() to get the latest QP int GetQP() const; int GetLoopfilterLevel() const; + signed char *GetCyclicRefreshMap() const; + int *GetDeltaQ() const; void ComputeQP(const VP9FrameParamsQpRTC &frame_params); // Feedback to rate control with the size of current encoded frame void PostEncodeUpdate(uint64_t encoded_frame_size); diff --git a/third_party/libvpx/vp9/simple_encode.cc b/third_party/libvpx/source/libvpx/vp9/simple_encode.cc similarity index 85% rename from third_party/libvpx/vp9/simple_encode.cc rename to third_party/libvpx/source/libvpx/vp9/simple_encode.cc index 46b25d1fdf82..6ba37a321cf0 100644 --- a/third_party/libvpx/vp9/simple_encode.cc +++ b/third_party/libvpx/source/libvpx/vp9/simple_encode.cc @@ -90,12 +90,20 @@ static int img_read(vpx_image_t *img, FILE *file) { return 1; } +// Assume every config in VP9EncoderConfig is less than 100 characters. +#define ENCODE_CONFIG_BUF_SIZE 100 +struct EncodeConfig { + char name[ENCODE_CONFIG_BUF_SIZE]; + char value[ENCODE_CONFIG_BUF_SIZE]; +}; + class SimpleEncode::EncodeImpl { public: VP9_COMP *cpi; vpx_img_fmt_t img_fmt; vpx_image_t tmp_img; std::vector first_pass_stats; + std::vector encode_config_list; }; static VP9_COMP *init_encoder(const VP9EncoderConfig *oxcf, @@ -199,6 +207,24 @@ static void update_motion_vector_info( } } +static void update_tpl_stats_info(const TplDepStats *input_tpl_stats_info, + const int show_frame_count, + TplStatsInfo *output_tpl_stats_info) { + int frame_idx; + for (frame_idx = 0; frame_idx < show_frame_count; ++frame_idx) { + output_tpl_stats_info[frame_idx].intra_cost = + input_tpl_stats_info[frame_idx].intra_cost; + output_tpl_stats_info[frame_idx].inter_cost = + input_tpl_stats_info[frame_idx].inter_cost; + output_tpl_stats_info[frame_idx].mc_flow = + input_tpl_stats_info[frame_idx].mc_flow; + output_tpl_stats_info[frame_idx].mc_dep_cost = + input_tpl_stats_info[frame_idx].mc_dep_cost; + output_tpl_stats_info[frame_idx].mc_ref_cost = + input_tpl_stats_info[frame_idx].mc_ref_cost; + } +} + static void update_frame_counts(const FRAME_COUNTS *input_counts, FrameCounts *output_counts) { // Init array sizes. @@ -478,6 +504,7 @@ static bool init_encode_frame_result(EncodeFrameResult *encode_frame_result, encode_frame_result->num_cols_4x4); encode_frame_result->motion_vector_info.resize( encode_frame_result->num_rows_4x4 * encode_frame_result->num_cols_4x4); + encode_frame_result->tpl_stats_info.resize(MAX_LAG_BUFFERS); if (encode_frame_result->coding_data.get() == nullptr) { return false; @@ -499,7 +526,7 @@ static void encode_frame_result_update_rq_history( } static void update_encode_frame_result( - EncodeFrameResult *encode_frame_result, + EncodeFrameResult *encode_frame_result, const int show_frame_count, const ENCODE_FRAME_RESULT *encode_frame_info) { encode_frame_result->coding_data_bit_size = encode_frame_result->coding_data_byte_size * 8; @@ -528,6 +555,10 @@ static void update_encode_frame_result( kMotionVectorSubPixelPrecision); update_frame_counts(&encode_frame_info->frame_counts, &encode_frame_result->frame_counts); + if (encode_frame_result->frame_type == kFrameTypeAltRef) { + update_tpl_stats_info(encode_frame_info->tpl_stats_info, show_frame_count, + &encode_frame_result->tpl_stats_info[0]); + } encode_frame_result_update_rq_history(&encode_frame_info->rq_history, encode_frame_result); } @@ -711,6 +742,61 @@ static void UpdateGroupOfPicture(const VP9_COMP *cpi, int start_coding_index, start_ref_frame_info, group_of_picture); } +#define SET_STRUCT_VALUE(config, structure, ret, field) \ + if (strcmp(config.name, #field) == 0) { \ + structure->field = atoi(config.value); \ + ret = 1; \ + } + +static void UpdateEncodeConfig(const EncodeConfig &config, + VP9EncoderConfig *oxcf) { + int ret = 0; + SET_STRUCT_VALUE(config, oxcf, ret, key_freq); + SET_STRUCT_VALUE(config, oxcf, ret, two_pass_vbrmin_section); + SET_STRUCT_VALUE(config, oxcf, ret, two_pass_vbrmax_section); + SET_STRUCT_VALUE(config, oxcf, ret, under_shoot_pct); + SET_STRUCT_VALUE(config, oxcf, ret, over_shoot_pct); + SET_STRUCT_VALUE(config, oxcf, ret, max_threads); + SET_STRUCT_VALUE(config, oxcf, ret, frame_parallel_decoding_mode); + SET_STRUCT_VALUE(config, oxcf, ret, tile_columns); + SET_STRUCT_VALUE(config, oxcf, ret, arnr_max_frames); + SET_STRUCT_VALUE(config, oxcf, ret, arnr_strength); + SET_STRUCT_VALUE(config, oxcf, ret, lag_in_frames); + SET_STRUCT_VALUE(config, oxcf, ret, encode_breakout); + SET_STRUCT_VALUE(config, oxcf, ret, enable_tpl_model); + SET_STRUCT_VALUE(config, oxcf, ret, enable_auto_arf); + if (strcmp(config.name, "rc_mode") == 0) { + int rc_mode = atoi(config.value); + if (rc_mode >= VPX_VBR && rc_mode <= VPX_Q) { + oxcf->rc_mode = (enum vpx_rc_mode)rc_mode; + ret = 1; + } else { + fprintf(stderr, "Invalid rc_mode value: %d\n", rc_mode); + } + } + SET_STRUCT_VALUE(config, oxcf, ret, cq_level); + if (ret == 0) { + fprintf(stderr, "Ignored unsupported encode_config %s\n", config.name); + } +} + +static VP9EncoderConfig GetEncodeConfig( + int frame_width, int frame_height, vpx_rational_t frame_rate, + int target_bitrate, int encode_speed, vpx_enc_pass enc_pass, + const std::vector &encode_config_list) { + VP9EncoderConfig oxcf = + vp9_get_encoder_config(frame_width, frame_height, frame_rate, + target_bitrate, encode_speed, enc_pass); + for (const auto &config : encode_config_list) { + UpdateEncodeConfig(config, &oxcf); + } + if (enc_pass == VPX_RC_FIRST_PASS) { + oxcf.lag_in_frames = 0; + } + oxcf.use_simple_encode_api = 1; + return oxcf; +} + SimpleEncode::SimpleEncode(int frame_width, int frame_height, int frame_rate_num, int frame_rate_den, int target_bitrate, int num_frames, @@ -748,20 +834,53 @@ void SimpleEncode::SetEncodeSpeed(int encode_speed) { encode_speed_ = encode_speed; } +StatusCode SimpleEncode::SetEncodeConfig(const char *name, const char *value) { + if (name == nullptr || value == nullptr) { + fprintf(stderr, "SetEncodeConfig: null pointer, name %p value %p\n", name, + value); + return StatusError; + } + EncodeConfig config; + snprintf(config.name, ENCODE_CONFIG_BUF_SIZE, "%s", name); + snprintf(config.value, ENCODE_CONFIG_BUF_SIZE, "%s", value); + impl_ptr_->encode_config_list.push_back(config); + return StatusOk; +} + +StatusCode SimpleEncode::DumpEncodeConfigs(int pass, FILE *fp) { + if (fp == nullptr) { + fprintf(stderr, "DumpEncodeConfigs: null pointer, fp %p\n", fp); + return StatusError; + } + vpx_enc_pass enc_pass; + if (pass == 1) { + enc_pass = VPX_RC_FIRST_PASS; + } else { + enc_pass = VPX_RC_LAST_PASS; + } + const vpx_rational_t frame_rate = + make_vpx_rational(frame_rate_num_, frame_rate_den_); + const VP9EncoderConfig oxcf = + GetEncodeConfig(frame_width_, frame_height_, frame_rate, target_bitrate_, + encode_speed_, enc_pass, impl_ptr_->encode_config_list); + vp9_dump_encoder_config(&oxcf, fp); + return StatusOk; +} + void SimpleEncode::ComputeFirstPassStats() { vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num_, frame_rate_den_); - const VP9EncoderConfig oxcf = - vp9_get_encoder_config(frame_width_, frame_height_, frame_rate, - target_bitrate_, encode_speed_, VPX_RC_FIRST_PASS); - VP9_COMP *cpi = init_encoder(&oxcf, impl_ptr_->img_fmt); - struct lookahead_ctx *lookahead = cpi->lookahead; + const VP9EncoderConfig oxcf = GetEncodeConfig( + frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_, + VPX_RC_FIRST_PASS, impl_ptr_->encode_config_list); + impl_ptr_->cpi = init_encoder(&oxcf, impl_ptr_->img_fmt); + struct lookahead_ctx *lookahead = impl_ptr_->cpi->lookahead; int i; int use_highbitdepth = 0; const int num_rows_16x16 = get_num_unit_16x16(frame_height_); const int num_cols_16x16 = get_num_unit_16x16(frame_width_); #if CONFIG_VP9_HIGHBITDEPTH - use_highbitdepth = cpi->common.use_highbitdepth; + use_highbitdepth = impl_ptr_->cpi->common.use_highbitdepth; #endif vpx_image_t img; vpx_img_alloc(&img, impl_ptr_->img_fmt, frame_width_, frame_height_, 1); @@ -787,30 +906,35 @@ void SimpleEncode::ComputeFirstPassStats() { ENCODE_FRAME_RESULT encode_frame_info; vp9_init_encode_frame_result(&encode_frame_info); // TODO(angiebird): Call vp9_first_pass directly - vp9_get_compressed_data(cpi, &frame_flags, &size, nullptr, &time_stamp, - &time_end, flush, &encode_frame_info); + vp9_get_compressed_data(impl_ptr_->cpi, &frame_flags, &size, nullptr, + &time_stamp, &time_end, flush, + &encode_frame_info); // vp9_get_compressed_data only generates first pass stats not // compresses data assert(size == 0); // Get vp9 first pass motion vector info. std::vector mv_info(num_rows_16x16 * num_cols_16x16); - update_motion_vector_info(cpi->fp_motion_vector_info, num_rows_16x16, - num_cols_16x16, mv_info.data(), - kMotionVectorFullPixelPrecision); + update_motion_vector_info( + impl_ptr_->cpi->fp_motion_vector_info, num_rows_16x16, + num_cols_16x16, mv_info.data(), kMotionVectorFullPixelPrecision); fp_motion_vector_info_.push_back(mv_info); } - impl_ptr_->first_pass_stats.push_back(vp9_get_frame_stats(&cpi->twopass)); + impl_ptr_->first_pass_stats.push_back( + vp9_get_frame_stats(&impl_ptr_->cpi->twopass)); } } - vp9_end_first_pass(cpi); // TODO(angiebird): Store the total_stats apart form first_pass_stats - impl_ptr_->first_pass_stats.push_back(vp9_get_total_stats(&cpi->twopass)); - free_encoder(cpi); - rewind(in_file_); - vpx_img_free(&img); + impl_ptr_->first_pass_stats.push_back( + vp9_get_total_stats(&impl_ptr_->cpi->twopass)); + vp9_end_first_pass(impl_ptr_->cpi); // Generate key_frame_map based on impl_ptr_->first_pass_stats. key_frame_map_ = ComputeKeyFrameMap(); + + free_encoder(impl_ptr_->cpi); + impl_ptr_->cpi = nullptr; + rewind(in_file_); + vpx_img_free(&img); } std::vector> SimpleEncode::ObserveFirstPassStats() { @@ -886,8 +1010,7 @@ T *GetVectorData(const std::vector &v) { static GOP_COMMAND GetGopCommand(const std::vector &gop_map, int start_show_index) { GOP_COMMAND gop_command; - if (gop_map.size() > 0) { - assert(static_cast(start_show_index) < gop_map.size()); + if (static_cast(start_show_index) < gop_map.size()) { assert((gop_map[start_show_index] & kGopMapFlagStart) != 0); int end_show_index = start_show_index + 1; // gop_map[end_show_index] & kGopMapFlagStart == 0 means this is @@ -913,9 +1036,10 @@ void SimpleEncode::StartEncode() { assert(impl_ptr_->first_pass_stats.size() > 0); vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num_, frame_rate_den_); - VP9EncoderConfig oxcf = - vp9_get_encoder_config(frame_width_, frame_height_, frame_rate, - target_bitrate_, encode_speed_, VPX_RC_LAST_PASS); + VP9EncoderConfig oxcf = GetEncodeConfig( + frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_, + VPX_RC_LAST_PASS, impl_ptr_->encode_config_list); + vpx_fixed_buf_t stats; stats.buf = GetVectorData(impl_ptr_->first_pass_stats); stats.sz = sizeof(impl_ptr_->first_pass_stats[0]) * @@ -930,6 +1054,11 @@ void SimpleEncode::StartEncode() { frame_coding_index_ = 0; show_frame_count_ = 0; + assert(impl_ptr_->cpi != nullptr); + FRAME_INFO frame_info = vp9_get_frame_info(&oxcf); + unsigned int screen_area = frame_info.frame_width * frame_info.frame_height; + vp9_init_vizier_params(&impl_ptr_->cpi->twopass, screen_area); + UpdateKeyFrameGroup(show_frame_count_); const GOP_COMMAND gop_command = GetGopCommand(gop_map_, show_frame_count_); @@ -965,8 +1094,7 @@ void SimpleEncode::UpdateKeyFrameGroup(int key_frame_show_index) { const VP9_COMP *cpi = impl_ptr_->cpi; key_frame_group_index_ = 0; key_frame_group_size_ = vp9_get_frames_to_next_key( - &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info, - key_frame_show_index, cpi->rc.min_gf_interval); + &cpi->oxcf, &cpi->twopass, key_frame_show_index, cpi->rc.min_gf_interval); assert(key_frame_group_size_ > 0); // Init the reference frame info when a new key frame group appears. InitRefFrameInfo(&ref_frame_info_); @@ -1083,7 +1211,10 @@ void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) { abort(); } - update_encode_frame_result(encode_frame_result, &encode_frame_info); + const GroupOfPicture group_of_picture = this->ObserveGroupOfPicture(); + const int show_frame_count = group_of_picture.show_frame_count; + update_encode_frame_result(encode_frame_result, show_frame_count, + &encode_frame_info); PostUpdateState(*encode_frame_result); } else { // TODO(angiebird): Clean up encode_frame_result. @@ -1117,7 +1248,7 @@ static int GetCodingFrameNumFromGopMap(const std::vector &gop_map) { start_show_index += gop_command.show_frame_count; coding_frame_count += gop_command_coding_frame_count(&gop_command); } - assert(start_show_index == gop_map.size()); + assert(static_cast(start_show_index) == gop_map.size()); return coding_frame_count; } @@ -1128,38 +1259,39 @@ int SimpleEncode::GetCodingFrameNum() const { } // These are the default settings for now. + TWO_PASS twopass; const int multi_layer_arf = 0; const int allow_alt_ref = 1; vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num_, frame_rate_den_); - const VP9EncoderConfig oxcf = - vp9_get_encoder_config(frame_width_, frame_height_, frame_rate, - target_bitrate_, encode_speed_, VPX_RC_LAST_PASS); + const VP9EncoderConfig oxcf = GetEncodeConfig( + frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_, + VPX_RC_LAST_PASS, impl_ptr_->encode_config_list); FRAME_INFO frame_info = vp9_get_frame_info(&oxcf); - FIRST_PASS_INFO first_pass_info; - fps_init_first_pass_info(&first_pass_info, + fps_init_first_pass_info(&twopass.first_pass_info, GetVectorData(impl_ptr_->first_pass_stats), num_frames_); - return vp9_get_coding_frame_num(&oxcf, &frame_info, &first_pass_info, - multi_layer_arf, allow_alt_ref); + unsigned int screen_area = frame_info.frame_width * frame_info.frame_height; + vp9_init_vizier_params(&twopass, screen_area); + return vp9_get_coding_frame_num(&oxcf, &twopass, &frame_info, multi_layer_arf, + allow_alt_ref); } std::vector SimpleEncode::ComputeKeyFrameMap() const { // The last entry of first_pass_stats is the overall stats. - assert(impl_ptr_->first_pass_stats.size() == num_frames_ + 1); + assert(impl_ptr_->first_pass_stats.size() == + static_cast(num_frames_) + 1); vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num_, frame_rate_den_); - const VP9EncoderConfig oxcf = - vp9_get_encoder_config(frame_width_, frame_height_, frame_rate, - target_bitrate_, encode_speed_, VPX_RC_LAST_PASS); - FRAME_INFO frame_info = vp9_get_frame_info(&oxcf); - FIRST_PASS_INFO first_pass_info; - fps_init_first_pass_info(&first_pass_info, + const VP9EncoderConfig oxcf = GetEncodeConfig( + frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_, + VPX_RC_LAST_PASS, impl_ptr_->encode_config_list); + TWO_PASS twopass; + fps_init_first_pass_info(&twopass.first_pass_info, GetVectorData(impl_ptr_->first_pass_stats), num_frames_); std::vector key_frame_map(num_frames_, 0); - vp9_get_key_frame_map(&oxcf, &frame_info, &first_pass_info, - GetVectorData(key_frame_map)); + vp9_get_key_frame_map(&oxcf, &twopass, GetVectorData(key_frame_map)); return key_frame_map; } diff --git a/third_party/libvpx/vp9/simple_encode.h b/third_party/libvpx/source/libvpx/vp9/simple_encode.h similarity index 85% rename from third_party/libvpx/vp9/simple_encode.h rename to third_party/libvpx/source/libvpx/vp9/simple_encode.h index dc055e9754be..8ec7069e836a 100644 --- a/third_party/libvpx/vp9/simple_encode.h +++ b/third_party/libvpx/source/libvpx/vp9/simple_encode.h @@ -19,13 +19,18 @@ namespace vp9 { +enum StatusCode { + StatusOk = 0, + StatusError, +}; + // TODO(angiebird): Add description for each frame type. enum FrameType { kFrameTypeKey = 0, - kFrameTypeInter, - kFrameTypeAltRef, - kFrameTypeOverlay, - kFrameTypeGolden, + kFrameTypeInter = 1, + kFrameTypeAltRef = 2, + kFrameTypeOverlay = 3, + kFrameTypeGolden = 4, }; // TODO(angiebird): Add description for each reference frame type. @@ -82,6 +87,24 @@ struct MotionVectorInfo { double mv_column[2]; }; +// Accumulated tpl stats of all blocks in one frame. +// For each frame, the tpl stats are computed per 32x32 block. +struct TplStatsInfo { + // Intra complexity: the sum of absolute transform difference (SATD) of + // intra predicted residuals. + int64_t intra_cost; + // Inter complexity: the SATD of inter predicted residuals. + int64_t inter_cost; + // Motion compensated information flow. It measures how much information + // is propagated from the current frame to other frames. + int64_t mc_flow; + // Motion compensated dependency cost. It equals to its own intra_cost + // plus the mc_flow. + int64_t mc_dep_cost; + // Motion compensated reference cost. + int64_t mc_ref_cost; +}; + struct RefFrameInfo { int coding_indexes[kRefFrameTypeMax]; @@ -256,6 +279,18 @@ struct EncodeFrameResult { // Similar to partition info, all 4x4 blocks inside the same partition block // share the same motion vector information. std::vector motion_vector_info; + // A vector of the tpl stats information. + // The tpl stats measure the complexity of a frame, as well as the + // information propagated along the motion trajectory between frames, in + // the reference frame structure. + // The tpl stats could be used as a more accurate spatial and temporal + // complexity measure in addition to the first pass stats. + // The vector contains tpl stats for all show frames in a GOP. + // The tpl stats stored in the vector is according to the encoding order. + // For example, suppose there are N show frames for the current GOP. + // Then tpl_stats_info[0] stores the information of the first frame to be + // encoded for this GOP, i.e, the AltRef frame. + std::vector tpl_stats_info; ImageBuffer coded_frame; // recode_count, q_index_history and rate_history are only available when @@ -322,6 +357,43 @@ class SimpleEncode { // at the cost of lower compression efficiency. void SetEncodeSpeed(int encode_speed); + // Set encoder config + // The following configs in VP9EncoderConfig are allowed to change in this + // function. See https://ffmpeg.org/ffmpeg-codecs.html#libvpx for each + // config's meaning. + // Configs in VP9EncoderConfig: Equivalent configs in ffmpeg: + // 1 key_freq -g + // 2 two_pass_vbrmin_section -minrate * 100LL / bit_rate + // 3 two_pass_vbrmax_section -maxrate * 100LL / bit_rate + // 4 under_shoot_pct -undershoot-pct + // 5 over_shoot_pct -overshoot-pct + // 6 max_threads -threads + // 7 frame_parallel_decoding_mode -frame-parallel + // 8 tile_column -tile-columns + // 9 arnr_max_frames -arnr-maxframes + // 10 arnr_strength -arnr-strength + // 11 lag_in_frames -rc_lookahead + // 12 encode_breakout -static-thresh + // 13 enable_tpl_model -enable-tpl + // 14 enable_auto_arf -auto-alt-ref + // 15 rc_mode + // Possible Settings: + // 0 - Variable Bit Rate (VPX_VBR) -b:v + // 1 - Constant Bit Rate (VPX_CBR) -b:v -minrate + // -maxrate + // two_pass_vbrmin_section == 100 i.e. bit_rate == minrate == maxrate + // two_pass_vbrmax_section == 100 + // 2 - Constrained Quality (VPX_CQ) -crf -b:v bit_rate + // 3 - Constant Quality (VPX_Q) -crf -b:v 0 + // See https://trac.ffmpeg.org/wiki/Encode/VP9 for more details. + // 16 cq_level see rc_mode for details. + StatusCode SetEncodeConfig(const char *name, const char *value); + + // A debug function that dumps configs from VP9EncoderConfig + // pass = 1: first pass, pass = 2: second pass + // fp: file pointer for dumping config + StatusCode DumpEncodeConfigs(int pass, FILE *fp); + // Makes encoder compute the first pass stats and store it at // impl_ptr_->first_pass_stats. key_frame_map_ is also computed based on the // first pass stats. diff --git a/third_party/libvpx/vp9/vp9_common.mk b/third_party/libvpx/source/libvpx/vp9/vp9_common.mk similarity index 100% rename from third_party/libvpx/vp9/vp9_common.mk rename to third_party/libvpx/source/libvpx/vp9/vp9_common.mk diff --git a/third_party/libvpx/vp9/vp9_cx_iface.c b/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c similarity index 84% rename from third_party/libvpx/vp9/vp9_cx_iface.c rename to third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c index 6caa4f7390c6..48d555532df1 100644 --- a/third_party/libvpx/vp9/vp9_cx_iface.c +++ b/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "vpx/vpx_encoder.h" +#include "vpx/vpx_ext_ratectrl.h" #include "vpx_dsp/psnr.h" #include "vpx_ports/vpx_once.h" #include "vpx_ports/static_assert.h" @@ -347,6 +348,24 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, } RANGE_CHECK(extra_cfg, color_space, VPX_CS_UNKNOWN, VPX_CS_SRGB); RANGE_CHECK(extra_cfg, color_range, VPX_CR_STUDIO_RANGE, VPX_CR_FULL_RANGE); + + // The range below shall be further tuned. + RANGE_CHECK(cfg, use_vizier_rc_params, 0, 1); + RANGE_CHECK(cfg, active_wq_factor.den, 1, 1000); + RANGE_CHECK(cfg, err_per_mb_factor.den, 1, 1000); + RANGE_CHECK(cfg, sr_default_decay_limit.den, 1, 1000); + RANGE_CHECK(cfg, sr_diff_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_err_per_mb_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_frame_min_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_frame_max_boost_subs_factor.den, 1, 1000); + RANGE_CHECK(cfg, kf_max_total_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, gf_max_total_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, gf_frame_max_boost_factor.den, 1, 1000); + RANGE_CHECK(cfg, zm_factor.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000); + RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000); + return VPX_CODEC_OK; } @@ -564,10 +583,6 @@ static vpx_codec_err_t set_encoder_config( vp9_set_first_pass_stats(oxcf, &cfg->rc_twopass_stats_in); -#if CONFIG_FP_MB_STATS - oxcf->firstpass_mb_stats_in = cfg->rc_firstpass_mb_stats_in; -#endif - oxcf->color_space = extra_cfg->color_space; oxcf->color_range = extra_cfg->color_range; oxcf->render_width = extra_cfg->render_width; @@ -633,7 +648,132 @@ static vpx_codec_err_t set_encoder_config( } if (get_level_index(oxcf->target_level) >= 0) config_target_level(oxcf); - // vp9_dump_encoder_config(oxcf); + oxcf->use_simple_encode_api = 0; + // vp9_dump_encoder_config(oxcf, stderr); + return VPX_CODEC_OK; +} + +static vpx_codec_err_t set_twopass_params_from_config( + const vpx_codec_enc_cfg_t *const cfg, struct VP9_COMP *cpi) { + if (!cfg->use_vizier_rc_params) return VPX_CODEC_OK; + if (cpi == NULL) return VPX_CODEC_ERROR; + + cpi->twopass.use_vizier_rc_params = cfg->use_vizier_rc_params; + + // The values set here are factors that will be applied to default values + // to get the final value used in the two pass code. Hence 1.0 will + // match the default behaviour when not using passed in values. + // We also apply limits here to prevent the user from applying settings + // that make no sense. + cpi->twopass.active_wq_factor = + (double)cfg->active_wq_factor.num / (double)cfg->active_wq_factor.den; + if (cpi->twopass.active_wq_factor < 0.25) + cpi->twopass.active_wq_factor = 0.25; + else if (cpi->twopass.active_wq_factor > 16.0) + cpi->twopass.active_wq_factor = 16.0; + + cpi->twopass.err_per_mb = + (double)cfg->err_per_mb_factor.num / (double)cfg->err_per_mb_factor.den; + if (cpi->twopass.err_per_mb < 0.25) + cpi->twopass.err_per_mb = 0.25; + else if (cpi->twopass.err_per_mb > 4.0) + cpi->twopass.err_per_mb = 4.0; + + cpi->twopass.sr_default_decay_limit = + (double)cfg->sr_default_decay_limit.num / + (double)cfg->sr_default_decay_limit.den; + if (cpi->twopass.sr_default_decay_limit < 0.25) + cpi->twopass.sr_default_decay_limit = 0.25; + // If the default changes this will need to change. + else if (cpi->twopass.sr_default_decay_limit > 1.33) + cpi->twopass.sr_default_decay_limit = 1.33; + + cpi->twopass.sr_diff_factor = + (double)cfg->sr_diff_factor.num / (double)cfg->sr_diff_factor.den; + if (cpi->twopass.sr_diff_factor < 0.25) + cpi->twopass.sr_diff_factor = 0.25; + else if (cpi->twopass.sr_diff_factor > 4.0) + cpi->twopass.sr_diff_factor = 4.0; + + cpi->twopass.kf_err_per_mb = (double)cfg->kf_err_per_mb_factor.num / + (double)cfg->kf_err_per_mb_factor.den; + if (cpi->twopass.kf_err_per_mb < 0.25) + cpi->twopass.kf_err_per_mb = 0.25; + else if (cpi->twopass.kf_err_per_mb > 4.0) + cpi->twopass.kf_err_per_mb = 4.0; + + cpi->twopass.kf_frame_min_boost = (double)cfg->kf_frame_min_boost_factor.num / + (double)cfg->kf_frame_min_boost_factor.den; + if (cpi->twopass.kf_frame_min_boost < 0.25) + cpi->twopass.kf_frame_min_boost = 0.25; + else if (cpi->twopass.kf_frame_min_boost > 4.0) + cpi->twopass.kf_frame_min_boost = 4.0; + + cpi->twopass.kf_frame_max_boost_first = + (double)cfg->kf_frame_max_boost_first_factor.num / + (double)cfg->kf_frame_max_boost_first_factor.den; + if (cpi->twopass.kf_frame_max_boost_first < 0.25) + cpi->twopass.kf_frame_max_boost_first = 0.25; + else if (cpi->twopass.kf_frame_max_boost_first > 4.0) + cpi->twopass.kf_frame_max_boost_first = 4.0; + + cpi->twopass.kf_frame_max_boost_subs = + (double)cfg->kf_frame_max_boost_subs_factor.num / + (double)cfg->kf_frame_max_boost_subs_factor.den; + if (cpi->twopass.kf_frame_max_boost_subs < 0.25) + cpi->twopass.kf_frame_max_boost_subs = 0.25; + else if (cpi->twopass.kf_frame_max_boost_subs > 4.0) + cpi->twopass.kf_frame_max_boost_subs = 4.0; + + cpi->twopass.kf_max_total_boost = (double)cfg->kf_max_total_boost_factor.num / + (double)cfg->kf_max_total_boost_factor.den; + if (cpi->twopass.kf_max_total_boost < 0.25) + cpi->twopass.kf_max_total_boost = 0.25; + else if (cpi->twopass.kf_max_total_boost > 4.0) + cpi->twopass.kf_max_total_boost = 4.0; + + cpi->twopass.gf_max_total_boost = (double)cfg->gf_max_total_boost_factor.num / + (double)cfg->gf_max_total_boost_factor.den; + if (cpi->twopass.gf_max_total_boost < 0.25) + cpi->twopass.gf_max_total_boost = 0.25; + else if (cpi->twopass.gf_max_total_boost > 4.0) + cpi->twopass.gf_max_total_boost = 4.0; + + cpi->twopass.gf_frame_max_boost = (double)cfg->gf_frame_max_boost_factor.num / + (double)cfg->gf_frame_max_boost_factor.den; + if (cpi->twopass.gf_frame_max_boost < 0.25) + cpi->twopass.gf_frame_max_boost = 0.25; + else if (cpi->twopass.gf_frame_max_boost > 4.0) + cpi->twopass.gf_frame_max_boost = 4.0; + + cpi->twopass.zm_factor = + (double)cfg->zm_factor.num / (double)cfg->zm_factor.den; + if (cpi->twopass.zm_factor < 0.25) + cpi->twopass.zm_factor = 0.25; + else if (cpi->twopass.zm_factor > 2.0) + cpi->twopass.zm_factor = 2.0; + + cpi->rd_ctrl.rd_mult_inter_qp_fac = (double)cfg->rd_mult_inter_qp_fac.num / + (double)cfg->rd_mult_inter_qp_fac.den; + if (cpi->rd_ctrl.rd_mult_inter_qp_fac < 0.25) + cpi->rd_ctrl.rd_mult_inter_qp_fac = 0.25; + else if (cpi->rd_ctrl.rd_mult_inter_qp_fac > 4.0) + cpi->rd_ctrl.rd_mult_inter_qp_fac = 4.0; + + cpi->rd_ctrl.rd_mult_arf_qp_fac = + (double)cfg->rd_mult_arf_qp_fac.num / (double)cfg->rd_mult_arf_qp_fac.den; + if (cpi->rd_ctrl.rd_mult_arf_qp_fac < 0.25) + cpi->rd_ctrl.rd_mult_arf_qp_fac = 0.25; + else if (cpi->rd_ctrl.rd_mult_arf_qp_fac > 4.0) + cpi->rd_ctrl.rd_mult_arf_qp_fac = 4.0; + + cpi->rd_ctrl.rd_mult_key_qp_fac = + (double)cfg->rd_mult_key_qp_fac.num / (double)cfg->rd_mult_key_qp_fac.den; + if (cpi->rd_ctrl.rd_mult_key_qp_fac < 0.25) + cpi->rd_ctrl.rd_mult_key_qp_fac = 0.25; + else if (cpi->rd_ctrl.rd_mult_key_qp_fac > 4.0) + cpi->rd_ctrl.rd_mult_key_qp_fac = 4.0; + return VPX_CODEC_OK; } @@ -663,6 +803,7 @@ static vpx_codec_err_t encoder_set_config(vpx_codec_alg_priv_t *ctx, if (res == VPX_CODEC_OK) { ctx->cfg = *cfg; set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); + set_twopass_params_from_config(&ctx->cfg, ctx->cpi); // On profile change, request a key frame force_key |= ctx->cpi->common.profile != ctx->oxcf.profile; vp9_change_config(ctx->cpi, &ctx->oxcf); @@ -689,12 +830,32 @@ static vpx_codec_err_t ctrl_get_quantizer64(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_OK; } +static vpx_codec_err_t ctrl_get_quantizer_svc_layers(vpx_codec_alg_priv_t *ctx, + va_list args) { + int *const arg = va_arg(args, int *); + int i; + if (arg == NULL) return VPX_CODEC_INVALID_PARAM; + for (i = 0; i < VPX_SS_MAX_LAYERS; i++) { + arg[i] = ctx->cpi->svc.base_qindex[i]; + } + return VPX_CODEC_OK; +} + +static vpx_codec_err_t ctrl_get_loopfilter_level(vpx_codec_alg_priv_t *ctx, + va_list args) { + int *const arg = va_arg(args, int *); + if (arg == NULL) return VPX_CODEC_INVALID_PARAM; + *arg = ctx->cpi->common.lf.filter_level; + return VPX_CODEC_OK; +} + static vpx_codec_err_t update_extra_cfg(vpx_codec_alg_priv_t *ctx, const struct vp9_extracfg *extra_cfg) { const vpx_codec_err_t res = validate_config(ctx, &ctx->cfg, extra_cfg); if (res == VPX_CODEC_OK) { ctx->extra_cfg = *extra_cfg; set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); + set_twopass_params_from_config(&ctx->cfg, ctx->cpi); vp9_change_config(ctx->cpi, &ctx->oxcf); } return res; @@ -885,6 +1046,18 @@ static vpx_codec_err_t ctrl_set_row_mt(vpx_codec_alg_priv_t *ctx, return update_extra_cfg(ctx, &extra_cfg); } +static vpx_codec_err_t ctrl_set_rtc_external_ratectrl(vpx_codec_alg_priv_t *ctx, + va_list args) { + VP9_COMP *const cpi = ctx->cpi; + const unsigned int data = va_arg(args, unsigned int); + if (data) { + cpi->compute_frame_low_motion_onepass = 0; + cpi->rc.constrain_gf_key_freq_onepass_vbr = 0; + cpi->cyclic_refresh->content_mode = 0; + } + return VPX_CODEC_OK; +} + static vpx_codec_err_t ctrl_enable_motion_vector_unit_test( vpx_codec_alg_priv_t *ctx, va_list args) { struct vp9_extracfg extra_cfg = ctx->extra_cfg; @@ -939,6 +1112,7 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx, #endif priv->cpi = vp9_create_compressor(&priv->oxcf, priv->buffer_pool); if (priv->cpi == NULL) res = VPX_CODEC_MEM_ERROR; + set_twopass_params_from_config(&priv->cfg, priv->cpi); } } @@ -1572,6 +1746,7 @@ static vpx_codec_err_t ctrl_set_svc_parameters(vpx_codec_alg_priv_t *ctx, lc->scaling_factor_num = params->scaling_factor_num[sl]; lc->scaling_factor_den = params->scaling_factor_den[sl]; lc->speed = params->speed_per_layer[sl]; + lc->loopfilter_ctrl = params->loopfilter_ctrl[sl]; } } @@ -1716,6 +1891,52 @@ static vpx_codec_err_t ctrl_set_postencode_drop(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_OK; } +static vpx_codec_err_t ctrl_set_disable_overshoot_maxq_cbr( + vpx_codec_alg_priv_t *ctx, va_list args) { + VP9_COMP *const cpi = ctx->cpi; + const unsigned int data = va_arg(args, unsigned int); + cpi->rc.disable_overshoot_maxq_cbr = data; + return VPX_CODEC_OK; +} + +static vpx_codec_err_t ctrl_set_disable_loopfilter(vpx_codec_alg_priv_t *ctx, + va_list args) { + VP9_COMP *const cpi = ctx->cpi; + const unsigned int data = va_arg(args, unsigned int); + cpi->loopfilter_ctrl = data; + return VPX_CODEC_OK; +} + +static vpx_codec_err_t ctrl_set_external_rate_control(vpx_codec_alg_priv_t *ctx, + va_list args) { + vpx_rc_funcs_t funcs = *CAST(VP9E_SET_EXTERNAL_RATE_CONTROL, args); + VP9_COMP *cpi = ctx->cpi; + EXT_RATECTRL *ext_ratectrl = &cpi->ext_ratectrl; + const VP9EncoderConfig *oxcf = &cpi->oxcf; + // TODO(angiebird): Check the possibility of this flag being set at pass == 1 + if (oxcf->pass == 2) { + const FRAME_INFO *frame_info = &cpi->frame_info; + vpx_rc_config_t ratectrl_config; + vpx_codec_err_t codec_status; + + ratectrl_config.frame_width = frame_info->frame_width; + ratectrl_config.frame_height = frame_info->frame_height; + ratectrl_config.show_frame_count = cpi->twopass.first_pass_info.num_frames; + + // TODO(angiebird): Double check whether this is the proper way to set up + // target_bitrate and frame_rate. + ratectrl_config.target_bitrate_kbps = (int)(oxcf->target_bandwidth / 1000); + ratectrl_config.frame_rate_num = oxcf->g_timebase.den; + ratectrl_config.frame_rate_den = oxcf->g_timebase.num; + + codec_status = vp9_extrc_create(funcs, ratectrl_config, ext_ratectrl); + if (codec_status != VPX_CODEC_OK) { + return codec_status; + } + } + return VPX_CODEC_OK; +} + static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { VP8_COPY_REFERENCE, ctrl_copy_reference }, @@ -1760,16 +1981,22 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { VP9E_SET_TARGET_LEVEL, ctrl_set_target_level }, { VP9E_SET_ROW_MT, ctrl_set_row_mt }, { VP9E_SET_POSTENCODE_DROP, ctrl_set_postencode_drop }, + { VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, ctrl_set_disable_overshoot_maxq_cbr }, { VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, ctrl_enable_motion_vector_unit_test }, { VP9E_SET_SVC_INTER_LAYER_PRED, ctrl_set_svc_inter_layer_pred }, { VP9E_SET_SVC_FRAME_DROP_LAYER, ctrl_set_svc_frame_drop_layer }, { VP9E_SET_SVC_GF_TEMPORAL_REF, ctrl_set_svc_gf_temporal_ref }, { VP9E_SET_SVC_SPATIAL_LAYER_SYNC, ctrl_set_svc_spatial_layer_sync }, { VP9E_SET_DELTA_Q_UV, ctrl_set_delta_q_uv }, + { VP9E_SET_DISABLE_LOOPFILTER, ctrl_set_disable_loopfilter }, + { VP9E_SET_RTC_EXTERNAL_RATECTRL, ctrl_set_rtc_external_ratectrl }, + { VP9E_SET_EXTERNAL_RATE_CONTROL, ctrl_set_external_rate_control }, // Getters { VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer }, { VP8E_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64 }, + { VP9E_GET_LAST_QUANTIZER_SVC_LAYERS, ctrl_get_quantizer_svc_layers }, + { VP9E_GET_LOOPFILTER_LEVEL, ctrl_get_loopfilter_level }, { VP9_GET_REFERENCE, ctrl_get_reference }, { VP9E_GET_SVC_LAYER_ID, ctrl_get_svc_layer_id }, { VP9E_GET_ACTIVEMAP, ctrl_get_active_map }, @@ -1832,14 +2059,30 @@ static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { VPX_SS_DEFAULT_LAYERS, // ss_number_layers { 0 }, - { 0 }, // ss_target_bitrate - 1, // ts_number_layers - { 0 }, // ts_target_bitrate - { 0 }, // ts_rate_decimator - 0, // ts_periodicity - { 0 }, // ts_layer_id - { 0 }, // layer_taget_bitrate - 0 // temporal_layering_mode + { 0 }, // ss_target_bitrate + 1, // ts_number_layers + { 0 }, // ts_target_bitrate + { 0 }, // ts_rate_decimator + 0, // ts_periodicity + { 0 }, // ts_layer_id + { 0 }, // layer_taget_bitrate + 0, // temporal_layering_mode + 0, // use_vizier_rc_params + { 1, 1 }, // active_wq_factor + { 1, 1 }, // err_per_mb_factor + { 1, 1 }, // sr_default_decay_limit + { 1, 1 }, // sr_diff_factor + { 1, 1 }, // kf_err_per_mb_factor + { 1, 1 }, // kf_frame_min_boost_factor + { 1, 1 }, // kf_frame_max_boost_first_factor + { 1, 1 }, // kf_frame_max_boost_subs_factor + { 1, 1 }, // kf_max_total_boost_factor + { 1, 1 }, // gf_max_total_boost_factor + { 1, 1 }, // gf_frame_max_boost_factor + { 1, 1 }, // zm_factor + { 1, 1 }, // rd_mult_inter_qp_fac + { 1, 1 }, // rd_mult_arf_qp_fac + { 1, 1 }, // rd_mult_key_qp_fac } }, }; @@ -1952,46 +2195,46 @@ VP9EncoderConfig vp9_get_encoder_config(int frame_width, int frame_height, return oxcf; } -#define DUMP_STRUCT_VALUE(struct, value) \ - printf(#value " %" PRId64 "\n", (int64_t)(struct)->value) +#define DUMP_STRUCT_VALUE(fp, structure, value) \ + fprintf(fp, #value " %" PRId64 "\n", (int64_t)(structure)->value) -void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf) { - DUMP_STRUCT_VALUE(oxcf, profile); - DUMP_STRUCT_VALUE(oxcf, bit_depth); - DUMP_STRUCT_VALUE(oxcf, width); - DUMP_STRUCT_VALUE(oxcf, height); - DUMP_STRUCT_VALUE(oxcf, input_bit_depth); - DUMP_STRUCT_VALUE(oxcf, init_framerate); +void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf, FILE *fp) { + DUMP_STRUCT_VALUE(fp, oxcf, profile); + DUMP_STRUCT_VALUE(fp, oxcf, bit_depth); + DUMP_STRUCT_VALUE(fp, oxcf, width); + DUMP_STRUCT_VALUE(fp, oxcf, height); + DUMP_STRUCT_VALUE(fp, oxcf, input_bit_depth); + DUMP_STRUCT_VALUE(fp, oxcf, init_framerate); // TODO(angiebird): dump g_timebase // TODO(angiebird): dump g_timebase_in_ts - DUMP_STRUCT_VALUE(oxcf, target_bandwidth); + DUMP_STRUCT_VALUE(fp, oxcf, target_bandwidth); - DUMP_STRUCT_VALUE(oxcf, noise_sensitivity); - DUMP_STRUCT_VALUE(oxcf, sharpness); - DUMP_STRUCT_VALUE(oxcf, speed); - DUMP_STRUCT_VALUE(oxcf, rc_max_intra_bitrate_pct); - DUMP_STRUCT_VALUE(oxcf, rc_max_inter_bitrate_pct); - DUMP_STRUCT_VALUE(oxcf, gf_cbr_boost_pct); + DUMP_STRUCT_VALUE(fp, oxcf, noise_sensitivity); + DUMP_STRUCT_VALUE(fp, oxcf, sharpness); + DUMP_STRUCT_VALUE(fp, oxcf, speed); + DUMP_STRUCT_VALUE(fp, oxcf, rc_max_intra_bitrate_pct); + DUMP_STRUCT_VALUE(fp, oxcf, rc_max_inter_bitrate_pct); + DUMP_STRUCT_VALUE(fp, oxcf, gf_cbr_boost_pct); - DUMP_STRUCT_VALUE(oxcf, mode); - DUMP_STRUCT_VALUE(oxcf, pass); + DUMP_STRUCT_VALUE(fp, oxcf, mode); + DUMP_STRUCT_VALUE(fp, oxcf, pass); // Key Framing Operations - DUMP_STRUCT_VALUE(oxcf, auto_key); - DUMP_STRUCT_VALUE(oxcf, key_freq); + DUMP_STRUCT_VALUE(fp, oxcf, auto_key); + DUMP_STRUCT_VALUE(fp, oxcf, key_freq); - DUMP_STRUCT_VALUE(oxcf, lag_in_frames); + DUMP_STRUCT_VALUE(fp, oxcf, lag_in_frames); // ---------------------------------------------------------------- // DATARATE CONTROL OPTIONS // vbr, cbr, constrained quality or constant quality - DUMP_STRUCT_VALUE(oxcf, rc_mode); + DUMP_STRUCT_VALUE(fp, oxcf, rc_mode); // buffer targeting aggressiveness - DUMP_STRUCT_VALUE(oxcf, under_shoot_pct); - DUMP_STRUCT_VALUE(oxcf, over_shoot_pct); + DUMP_STRUCT_VALUE(fp, oxcf, under_shoot_pct); + DUMP_STRUCT_VALUE(fp, oxcf, over_shoot_pct); // buffering parameters // TODO(angiebird): dump tarting_buffer_level_ms @@ -1999,37 +2242,37 @@ void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf) { // TODO(angiebird): dump maximum_buffer_size_ms // Frame drop threshold. - DUMP_STRUCT_VALUE(oxcf, drop_frames_water_mark); + DUMP_STRUCT_VALUE(fp, oxcf, drop_frames_water_mark); // controlling quality - DUMP_STRUCT_VALUE(oxcf, fixed_q); - DUMP_STRUCT_VALUE(oxcf, worst_allowed_q); - DUMP_STRUCT_VALUE(oxcf, best_allowed_q); - DUMP_STRUCT_VALUE(oxcf, cq_level); - DUMP_STRUCT_VALUE(oxcf, aq_mode); + DUMP_STRUCT_VALUE(fp, oxcf, fixed_q); + DUMP_STRUCT_VALUE(fp, oxcf, worst_allowed_q); + DUMP_STRUCT_VALUE(fp, oxcf, best_allowed_q); + DUMP_STRUCT_VALUE(fp, oxcf, cq_level); + DUMP_STRUCT_VALUE(fp, oxcf, aq_mode); // Special handling of Adaptive Quantization for AltRef frames - DUMP_STRUCT_VALUE(oxcf, alt_ref_aq); + DUMP_STRUCT_VALUE(fp, oxcf, alt_ref_aq); // Internal frame size scaling. - DUMP_STRUCT_VALUE(oxcf, resize_mode); - DUMP_STRUCT_VALUE(oxcf, scaled_frame_width); - DUMP_STRUCT_VALUE(oxcf, scaled_frame_height); + DUMP_STRUCT_VALUE(fp, oxcf, resize_mode); + DUMP_STRUCT_VALUE(fp, oxcf, scaled_frame_width); + DUMP_STRUCT_VALUE(fp, oxcf, scaled_frame_height); // Enable feature to reduce the frame quantization every x frames. - DUMP_STRUCT_VALUE(oxcf, frame_periodic_boost); + DUMP_STRUCT_VALUE(fp, oxcf, frame_periodic_boost); // two pass datarate control - DUMP_STRUCT_VALUE(oxcf, two_pass_vbrbias); - DUMP_STRUCT_VALUE(oxcf, two_pass_vbrmin_section); - DUMP_STRUCT_VALUE(oxcf, two_pass_vbrmax_section); - DUMP_STRUCT_VALUE(oxcf, vbr_corpus_complexity); + DUMP_STRUCT_VALUE(fp, oxcf, two_pass_vbrbias); + DUMP_STRUCT_VALUE(fp, oxcf, two_pass_vbrmin_section); + DUMP_STRUCT_VALUE(fp, oxcf, two_pass_vbrmax_section); + DUMP_STRUCT_VALUE(fp, oxcf, vbr_corpus_complexity); // END DATARATE CONTROL OPTIONS // ---------------------------------------------------------------- // Spatial and temporal scalability. - DUMP_STRUCT_VALUE(oxcf, ss_number_layers); - DUMP_STRUCT_VALUE(oxcf, ts_number_layers); + DUMP_STRUCT_VALUE(fp, oxcf, ss_number_layers); + DUMP_STRUCT_VALUE(fp, oxcf, ts_number_layers); // Bitrate allocation for spatial layers. // TODO(angiebird): dump layer_target_bitrate[VPX_MAX_LAYERS] @@ -2037,45 +2280,42 @@ void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf) { // TODO(angiebird): dump ss_enable_auto_arf[VPX_SS_MAX_LAYERS] // TODO(angiebird): dump ts_rate_decimator[VPX_TS_MAX_LAYERS] - DUMP_STRUCT_VALUE(oxcf, enable_auto_arf); - DUMP_STRUCT_VALUE(oxcf, encode_breakout); - DUMP_STRUCT_VALUE(oxcf, error_resilient_mode); - DUMP_STRUCT_VALUE(oxcf, frame_parallel_decoding_mode); + DUMP_STRUCT_VALUE(fp, oxcf, enable_auto_arf); + DUMP_STRUCT_VALUE(fp, oxcf, encode_breakout); + DUMP_STRUCT_VALUE(fp, oxcf, error_resilient_mode); + DUMP_STRUCT_VALUE(fp, oxcf, frame_parallel_decoding_mode); - DUMP_STRUCT_VALUE(oxcf, arnr_max_frames); - DUMP_STRUCT_VALUE(oxcf, arnr_strength); + DUMP_STRUCT_VALUE(fp, oxcf, arnr_max_frames); + DUMP_STRUCT_VALUE(fp, oxcf, arnr_strength); - DUMP_STRUCT_VALUE(oxcf, min_gf_interval); - DUMP_STRUCT_VALUE(oxcf, max_gf_interval); + DUMP_STRUCT_VALUE(fp, oxcf, min_gf_interval); + DUMP_STRUCT_VALUE(fp, oxcf, max_gf_interval); - DUMP_STRUCT_VALUE(oxcf, tile_columns); - DUMP_STRUCT_VALUE(oxcf, tile_rows); + DUMP_STRUCT_VALUE(fp, oxcf, tile_columns); + DUMP_STRUCT_VALUE(fp, oxcf, tile_rows); - DUMP_STRUCT_VALUE(oxcf, enable_tpl_model); + DUMP_STRUCT_VALUE(fp, oxcf, enable_tpl_model); - DUMP_STRUCT_VALUE(oxcf, max_threads); + DUMP_STRUCT_VALUE(fp, oxcf, max_threads); - DUMP_STRUCT_VALUE(oxcf, target_level); + DUMP_STRUCT_VALUE(fp, oxcf, target_level); // TODO(angiebird): dump two_pass_stats_in - -#if CONFIG_FP_MB_STATS - // TODO(angiebird): dump firstpass_mb_stats_in -#endif - - DUMP_STRUCT_VALUE(oxcf, tuning); - DUMP_STRUCT_VALUE(oxcf, content); + DUMP_STRUCT_VALUE(fp, oxcf, tuning); + DUMP_STRUCT_VALUE(fp, oxcf, content); #if CONFIG_VP9_HIGHBITDEPTH - DUMP_STRUCT_VALUE(oxcf, use_highbitdepth); + DUMP_STRUCT_VALUE(fp, oxcf, use_highbitdepth); #endif - DUMP_STRUCT_VALUE(oxcf, color_space); - DUMP_STRUCT_VALUE(oxcf, color_range); - DUMP_STRUCT_VALUE(oxcf, render_width); - DUMP_STRUCT_VALUE(oxcf, render_height); - DUMP_STRUCT_VALUE(oxcf, temporal_layering_mode); - - DUMP_STRUCT_VALUE(oxcf, row_mt); - DUMP_STRUCT_VALUE(oxcf, motion_vector_unit_test); + DUMP_STRUCT_VALUE(fp, oxcf, color_space); + DUMP_STRUCT_VALUE(fp, oxcf, color_range); + DUMP_STRUCT_VALUE(fp, oxcf, render_width); + DUMP_STRUCT_VALUE(fp, oxcf, render_height); + DUMP_STRUCT_VALUE(fp, oxcf, temporal_layering_mode); + + DUMP_STRUCT_VALUE(fp, oxcf, row_mt); + DUMP_STRUCT_VALUE(fp, oxcf, motion_vector_unit_test); + DUMP_STRUCT_VALUE(fp, oxcf, delta_q_uv); + DUMP_STRUCT_VALUE(fp, oxcf, use_simple_encode_api); } FRAME_INFO vp9_get_frame_info(const VP9EncoderConfig *oxcf) { diff --git a/third_party/libvpx/vp9/vp9_cx_iface.h b/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.h similarity index 95% rename from third_party/libvpx/vp9/vp9_cx_iface.h rename to third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.h index 3188575dd686..01338adb4e31 100644 --- a/third_party/libvpx/vp9/vp9_cx_iface.h +++ b/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.h @@ -22,7 +22,7 @@ VP9EncoderConfig vp9_get_encoder_config(int frame_width, int frame_height, int target_bitrate, int encode_speed, vpx_enc_pass enc_pass); -void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf); +void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf, FILE *fp); FRAME_INFO vp9_get_frame_info(const VP9EncoderConfig *oxcf); diff --git a/third_party/libvpx/vp9/vp9_dx_iface.c b/third_party/libvpx/source/libvpx/vp9/vp9_dx_iface.c similarity index 100% rename from third_party/libvpx/vp9/vp9_dx_iface.c rename to third_party/libvpx/source/libvpx/vp9/vp9_dx_iface.c diff --git a/third_party/libvpx/vp9/vp9_dx_iface.h b/third_party/libvpx/source/libvpx/vp9/vp9_dx_iface.h similarity index 100% rename from third_party/libvpx/vp9/vp9_dx_iface.h rename to third_party/libvpx/source/libvpx/vp9/vp9_dx_iface.h diff --git a/third_party/libvpx/vp9/vp9_iface_common.c b/third_party/libvpx/source/libvpx/vp9/vp9_iface_common.c similarity index 100% rename from third_party/libvpx/vp9/vp9_iface_common.c rename to third_party/libvpx/source/libvpx/vp9/vp9_iface_common.c diff --git a/third_party/libvpx/vp9/vp9_iface_common.h b/third_party/libvpx/source/libvpx/vp9/vp9_iface_common.h similarity index 100% rename from third_party/libvpx/vp9/vp9_iface_common.h rename to third_party/libvpx/source/libvpx/vp9/vp9_iface_common.h diff --git a/third_party/libvpx/vp9/vp9cx.mk b/third_party/libvpx/source/libvpx/vp9/vp9cx.mk similarity index 98% rename from third_party/libvpx/vp9/vp9cx.mk rename to third_party/libvpx/source/libvpx/vp9/vp9cx.mk index 666f228827fa..38e99165af47 100644 --- a/third_party/libvpx/vp9/vp9cx.mk +++ b/third_party/libvpx/source/libvpx/vp9/vp9cx.mk @@ -96,6 +96,8 @@ VP9_CX_SRCS-yes += encoder/vp9_skin_detection.c VP9_CX_SRCS-yes += encoder/vp9_skin_detection.h VP9_CX_SRCS-yes += encoder/vp9_noise_estimate.c VP9_CX_SRCS-yes += encoder/vp9_noise_estimate.h +VP9_CX_SRCS-yes += encoder/vp9_ext_ratectrl.c +VP9_CX_SRCS-yes += encoder/vp9_ext_ratectrl.h ifeq ($(CONFIG_VP9_POSTPROC),yes) VP9_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/vp9_postproc.h VP9_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/vp9_postproc.c diff --git a/third_party/libvpx/vp9/vp9dx.mk b/third_party/libvpx/source/libvpx/vp9/vp9dx.mk similarity index 100% rename from third_party/libvpx/vp9/vp9dx.mk rename to third_party/libvpx/source/libvpx/vp9/vp9dx.mk diff --git a/third_party/libvpx/vpx/exports_com b/third_party/libvpx/source/libvpx/vpx/exports_com similarity index 100% rename from third_party/libvpx/vpx/exports_com rename to third_party/libvpx/source/libvpx/vpx/exports_com diff --git a/third_party/libvpx/vpx/exports_dec b/third_party/libvpx/source/libvpx/vpx/exports_dec similarity index 100% rename from third_party/libvpx/vpx/exports_dec rename to third_party/libvpx/source/libvpx/vpx/exports_dec diff --git a/third_party/libvpx/vpx/exports_enc b/third_party/libvpx/source/libvpx/vpx/exports_enc similarity index 100% rename from third_party/libvpx/vpx/exports_enc rename to third_party/libvpx/source/libvpx/vpx/exports_enc diff --git a/third_party/libvpx/vpx/internal/vpx_codec_internal.h b/third_party/libvpx/source/libvpx/vpx/internal/vpx_codec_internal.h similarity index 99% rename from third_party/libvpx/vpx/internal/vpx_codec_internal.h rename to third_party/libvpx/source/libvpx/vpx/internal/vpx_codec_internal.h index 4ef93057f5eb..961b0bfe4c19 100644 --- a/third_party/libvpx/vpx/internal/vpx_codec_internal.h +++ b/third_party/libvpx/source/libvpx/vpx/internal/vpx_codec_internal.h @@ -283,7 +283,7 @@ typedef const struct vpx_codec_enc_cfg_map { vpx_codec_enc_cfg_t cfg; } vpx_codec_enc_cfg_map_t; -/*!\brief Decoder algorithm interface interface +/*!\brief Decoder algorithm interface * * All decoders \ref MUST expose a variable of this type. */ diff --git a/third_party/libvpx/source/libvpx/vpx/internal/vpx_ratectrl_rtc.h b/third_party/libvpx/source/libvpx/vpx/internal/vpx_ratectrl_rtc.h new file mode 100644 index 000000000000..0474e0a85b01 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vpx/internal/vpx_ratectrl_rtc.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_VPX_RATECTRL_RTC_H_ +#define VPX_VPX_RATECTRL_RTC_H_ + +#include "vpx/vpx_encoder.h" + +namespace libvpx { +struct VpxRateControlRtcConfig { + public: + VpxRateControlRtcConfig() { + width = 1280; + height = 720; + max_quantizer = 63; + min_quantizer = 2; + target_bandwidth = 1000; + buf_initial_sz = 600; + buf_optimal_sz = 600; + buf_sz = 1000; + undershoot_pct = overshoot_pct = 50; + max_intra_bitrate_pct = 50; + max_inter_bitrate_pct = 0; + framerate = 30.0; + ts_number_layers = 1; + rc_mode = VPX_CBR; + aq_mode = 0; + layer_target_bitrate[0] = static_cast(target_bandwidth); + ts_rate_decimator[0] = 1; + } + + int width; + int height; + // 0-63 + int max_quantizer; + int min_quantizer; + int64_t target_bandwidth; + int64_t buf_initial_sz; + int64_t buf_optimal_sz; + int64_t buf_sz; + int undershoot_pct; + int overshoot_pct; + int max_intra_bitrate_pct; + int max_inter_bitrate_pct; + double framerate; + // Number of temporal layers + int ts_number_layers; + int layer_target_bitrate[VPX_MAX_LAYERS]; + int ts_rate_decimator[VPX_TS_MAX_LAYERS]; + // vbr, cbr + enum vpx_rc_mode rc_mode; + int aq_mode; +}; +} // namespace libvpx +#endif diff --git a/third_party/libvpx/vpx/src/vpx_codec.c b/third_party/libvpx/source/libvpx/vpx/src/vpx_codec.c similarity index 100% rename from third_party/libvpx/vpx/src/vpx_codec.c rename to third_party/libvpx/source/libvpx/vpx/src/vpx_codec.c diff --git a/third_party/libvpx/vpx/src/vpx_decoder.c b/third_party/libvpx/source/libvpx/vpx/src/vpx_decoder.c similarity index 100% rename from third_party/libvpx/vpx/src/vpx_decoder.c rename to third_party/libvpx/source/libvpx/vpx/src/vpx_decoder.c diff --git a/third_party/libvpx/vpx/src/vpx_encoder.c b/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c similarity index 100% rename from third_party/libvpx/vpx/src/vpx_encoder.c rename to third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c diff --git a/third_party/libvpx/vpx/src/vpx_image.c b/third_party/libvpx/source/libvpx/vpx/src/vpx_image.c similarity index 97% rename from third_party/libvpx/vpx/src/vpx_image.c rename to third_party/libvpx/source/libvpx/vpx/src/vpx_image.c index ff496b5d34f1..f9f0dd6025d2 100644 --- a/third_party/libvpx/vpx/src/vpx_image.c +++ b/third_party/libvpx/source/libvpx/vpx/src/vpx_image.c @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include #include @@ -22,7 +23,9 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned char *img_data) { unsigned int h, w, s, xcs, ycs, bps; unsigned int stride_in_bytes; - int align; + unsigned int align; + + if (img != NULL) memset(img, 0, sizeof(vpx_image_t)); /* Treat align==0 like align==1 */ if (!buf_align) buf_align = 1; @@ -88,8 +91,6 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, if (!img) goto fail; img->self_allocd = 1; - } else { - memset(img, 0, sizeof(vpx_image_t)); } img->img_data = img_data; @@ -152,9 +153,8 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - unsigned char *data; - - if (x + w <= img->w && y + h <= img->h) { + if (x <= UINT_MAX - w && x + w <= img->w && y <= UINT_MAX - h && + y + h <= img->h) { img->d_w = w; img->d_h = h; @@ -165,7 +165,7 @@ int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y, } else { const int bytes_per_sample = (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1; - data = img->img_data; + unsigned char *data = img->img_data; if (img->fmt & VPX_IMG_FMT_HAS_ALPHA) { img->planes[VPX_PLANE_ALPHA] = diff --git a/third_party/libvpx/vpx/vp8.h b/third_party/libvpx/source/libvpx/vpx/vp8.h similarity index 100% rename from third_party/libvpx/vpx/vp8.h rename to third_party/libvpx/source/libvpx/vpx/vp8.h diff --git a/third_party/libvpx/vpx/vp8cx.h b/third_party/libvpx/source/libvpx/vpx/vp8cx.h similarity index 92% rename from third_party/libvpx/vpx/vp8cx.h rename to third_party/libvpx/source/libvpx/vpx/vp8cx.h index dcdd710c0ba1..47c38d3b5ee2 100644 --- a/third_party/libvpx/vpx/vp8cx.h +++ b/third_party/libvpx/source/libvpx/vpx/vp8cx.h @@ -17,6 +17,7 @@ */ #include "./vp8.h" #include "./vpx_encoder.h" +#include "./vpx_ext_ratectrl.h" /*!\file * \brief Provides definitions for using VP8 or VP9 encoder algorithm within the @@ -684,6 +685,74 @@ enum vp8e_enc_control_id { * Supported in codecs: VP9 */ VP9E_SET_DELTA_Q_UV, + + /*!\brief Codec control function to disable increase Q on overshoot in CBR. + * + * 0: On (default), 1: Disable. + * + * Supported in codecs: VP9 + */ + VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, + + /*!\brief Codec control function to disable loopfilter. + * + * 0: Loopfilter on all frames, 1: Disable on non reference frames. + * 2: Disable on all frames. + * + * Supported in codecs: VP9 + */ + VP9E_SET_DISABLE_LOOPFILTER, + + /*!\brief Codec control function to enable external rate control library. + * + * args[0]: path of the rate control library + * + * args[1]: private config of the rate control library + * + * Supported in codecs: VP9 + */ + VP9E_SET_EXTERNAL_RATE_CONTROL, + + /*!\brief Codec control to disable internal features in rate control. + * + * This will do 3 things, only for 1 pass: + * - Turn off low motion computation + * - Turn off gf update constraint on key frame frequency + * - Turn off content mode for cyclic refresh + * + * With those, the rate control is expected to work exactly the same as the + * interface provided in ratectrl_rtc.cc/h + * + * Supported in codecs: VP9 + */ + VP9E_SET_RTC_EXTERNAL_RATECTRL, + + /*!\brief Codec control function to get loopfilter level in the encoder. + * + * Supported in codecs: VP9 + */ + VP9E_GET_LOOPFILTER_LEVEL, + + /*!\brief Codec control to get last quantizers for all spatial layers. + * + * Return value uses an array of internal quantizers scale defined by the + * codec, for all spatial layers. + * The size of the array passed in should be #VPX_SS_MAX_LAYERS. + * + * Supported in codecs: VP9 + */ + VP9E_GET_LAST_QUANTIZER_SVC_LAYERS, + + /*!\brief Codec control to disable internal features in rate control. + * + * This will turn off cyclic refresh for vp8. + * + * With this, the rate control is expected to work exactly the same as the + * interface provided in vp8_ratectrl_rtc.cc/h + * + * Supported in codecs: VP8 + */ + VP8E_SET_RTC_EXTERNAL_RATECTRL, }; /*!\brief vpx 1-D scaling mode @@ -739,8 +808,8 @@ typedef struct vpx_roi_map { unsigned int rows; /**< Number of rows. */ unsigned int cols; /**< Number of columns. */ /*! VP8 only uses the first 4 segments. VP9 uses 8 segments. */ - int delta_q[8]; /**< Quantizer deltas. */ - int delta_lf[8]; /**< Loop filter deltas. */ + int delta_q[8]; /**< Quantizer deltas. Valid range: [-63, 63].*/ + int delta_lf[8]; /**< Loop filter deltas. Valid range: [-63, 63].*/ /*! skip and ref frame segment is only used in VP9. */ int skip[8]; /**< Skip this block. */ int ref_frame[8]; /**< Reference frame for this block. */ @@ -941,6 +1010,9 @@ VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *) #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *) #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER_64 +VPX_CTRL_USE_TYPE(VP9E_GET_LAST_QUANTIZER_SVC_LAYERS, int *) +#define VPX_CTRL_VP9E_GET_LAST_QUANTIZER_SVC_LAYERS + VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID, vpx_svc_layer_id_t *) #define VPX_CTRL_VP9E_GET_SVC_LAYER_ID @@ -1009,6 +1081,9 @@ VPX_CTRL_USE_TYPE(VP9E_SET_ROW_MT, unsigned int) VPX_CTRL_USE_TYPE(VP9E_GET_LEVEL, int *) #define VPX_CTRL_VP9E_GET_LEVEL +VPX_CTRL_USE_TYPE(VP9E_GET_LOOPFILTER_LEVEL, int *) +#define VPX_CTRL_VP9E_GET_LOOPFILTER_LEVEL + VPX_CTRL_USE_TYPE(VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, unsigned int) #define VPX_CTRL_VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST @@ -1034,6 +1109,21 @@ VPX_CTRL_USE_TYPE(VP9E_SET_POSTENCODE_DROP, unsigned int) VPX_CTRL_USE_TYPE(VP9E_SET_DELTA_Q_UV, int) #define VPX_CTRL_VP9E_SET_DELTA_Q_UV +VPX_CTRL_USE_TYPE(VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, int) +#define VPX_CTRL_VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR + +VPX_CTRL_USE_TYPE(VP9E_SET_DISABLE_LOOPFILTER, int) +#define VPX_CTRL_VP9E_SET_DISABLE_LOOPFILTER + +VPX_CTRL_USE_TYPE(VP9E_SET_RTC_EXTERNAL_RATECTRL, int) +#define VPX_CTRL_VP9E_SET_RTC_EXTERNAL_RATECTRL + +VPX_CTRL_USE_TYPE(VP8E_SET_RTC_EXTERNAL_RATECTRL, int) +#define VPX_CTRL_VP8E_SET_RTC_EXTERNAL_RATECTRL + +VPX_CTRL_USE_TYPE(VP9E_SET_EXTERNAL_RATE_CONTROL, vpx_rc_funcs_t *) +#define VPX_CTRL_VP9E_SET_EXTERNAL_RATE_CONTROL + /*!\endcond */ /*! @} - end defgroup vp8_encoder */ #ifdef __cplusplus diff --git a/third_party/libvpx/vpx/vp8dx.h b/third_party/libvpx/source/libvpx/vpx/vp8dx.h similarity index 100% rename from third_party/libvpx/vpx/vp8dx.h rename to third_party/libvpx/source/libvpx/vpx/vp8dx.h diff --git a/third_party/libvpx/vpx/vpx_codec.h b/third_party/libvpx/source/libvpx/vpx/vpx_codec.h similarity index 100% rename from third_party/libvpx/vpx/vpx_codec.h rename to third_party/libvpx/source/libvpx/vpx/vpx_codec.h diff --git a/third_party/libvpx/vpx/vpx_codec.mk b/third_party/libvpx/source/libvpx/vpx/vpx_codec.mk similarity index 91% rename from third_party/libvpx/vpx/vpx_codec.mk rename to third_party/libvpx/source/libvpx/vpx/vpx_codec.mk index 4ed77ad6d9df..de86579d58c9 100644 --- a/third_party/libvpx/vpx/vpx_codec.mk +++ b/third_party/libvpx/source/libvpx/vpx/vpx_codec.mk @@ -24,6 +24,7 @@ API_DOC_SRCS-$(CONFIG_VP8_DECODER) += vp8dx.h API_DOC_SRCS-yes += vpx_codec.h API_DOC_SRCS-yes += vpx_decoder.h API_DOC_SRCS-yes += vpx_encoder.h +API_DOC_SRCS-yes += vpx_ext_ratectrl.h API_DOC_SRCS-yes += vpx_frame_buffer.h API_DOC_SRCS-yes += vpx_image.h @@ -32,6 +33,7 @@ API_SRCS-yes += vpx_decoder.h API_SRCS-yes += src/vpx_encoder.c API_SRCS-yes += vpx_encoder.h API_SRCS-yes += internal/vpx_codec_internal.h +API_SRCS-yes += internal/vpx_ratectrl_rtc.h API_SRCS-yes += src/vpx_codec.c API_SRCS-yes += src/vpx_image.c API_SRCS-yes += vpx_codec.h @@ -39,3 +41,4 @@ API_SRCS-yes += vpx_codec.mk API_SRCS-yes += vpx_frame_buffer.h API_SRCS-yes += vpx_image.h API_SRCS-yes += vpx_integer.h +API_SRCS-yes += vpx_ext_ratectrl.h diff --git a/third_party/libvpx/vpx/vpx_decoder.h b/third_party/libvpx/source/libvpx/vpx/vpx_decoder.h similarity index 100% rename from third_party/libvpx/vpx/vpx_decoder.h rename to third_party/libvpx/source/libvpx/vpx/vpx_decoder.h diff --git a/third_party/libvpx/vpx/vpx_encoder.h b/third_party/libvpx/source/libvpx/vpx/vpx_encoder.h similarity index 86% rename from third_party/libvpx/vpx/vpx_encoder.h rename to third_party/libvpx/source/libvpx/vpx/vpx_encoder.h index c84d40f7f7f1..21254bb547fc 100644 --- a/third_party/libvpx/vpx/vpx_encoder.h +++ b/third_party/libvpx/source/libvpx/vpx/vpx_encoder.h @@ -30,6 +30,7 @@ extern "C" { #endif #include "./vpx_codec.h" +#include "./vpx_ext_ratectrl.h" /*! Temporal Scalability: Maximum length of the sequence defining frame * layer membership @@ -57,7 +58,8 @@ extern "C" { * fields to structures */ #define VPX_ENCODER_ABI_VERSION \ - (14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ + (15 + VPX_CODEC_ABI_VERSION + \ + VPX_EXT_RATECTRL_ABI_VERSION) /**<\hideinitializer*/ /*! \brief Encoder capabilities bitfield * @@ -455,7 +457,7 @@ typedef struct vpx_codec_enc_cfg { /*!\brief Target data rate * - * Target bandwidth to use for this stream, in kilobits per second. + * Target bitrate to use for this stream, in kilobits per second. */ unsigned int rc_target_bitrate; @@ -496,7 +498,7 @@ typedef struct vpx_codec_enc_cfg { * undershoot level (current rate vs target) beyond which more aggressive * corrective measures are taken. * * - * Valid values in the range VP8:0-1000 VP9: 0-100. + * Valid values in the range VP8:0-100 VP9: 0-100. */ unsigned int rc_undershoot_pct; @@ -511,7 +513,7 @@ typedef struct vpx_codec_enc_cfg { * overshoot level (current rate vs target) beyond which more aggressive * corrective measures are taken. * - * Valid values in the range VP8:0-1000 VP9: 0-100. + * Valid values in the range VP8:0-100 VP9: 0-100. */ unsigned int rc_overshoot_pct; @@ -691,6 +693,151 @@ typedef struct vpx_codec_enc_cfg { * */ int temporal_layering_mode; + + /*!\brief A flag indicating whether to use external rate control parameters. + * By default is 0. If set to 1, the following parameters will be used in the + * rate control system. + */ + int use_vizier_rc_params; + + /*!\brief Active worst quality factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t active_wq_factor; + + /*!\brief Error per macroblock adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t err_per_mb_factor; + + /*!\brief Second reference default decay limit. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t sr_default_decay_limit; + + /*!\brief Second reference difference factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t sr_diff_factor; + + /*!\brief Keyframe error per macroblock adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t kf_err_per_mb_factor; + + /*!\brief Keyframe minimum boost adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t kf_frame_min_boost_factor; + + /*!\brief Keyframe maximum boost adjustment factor, for the first keyframe + * in a chunk. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t kf_frame_max_boost_first_factor; + + /*!\brief Keyframe maximum boost adjustment factor, for subsequent keyframes. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t kf_frame_max_boost_subs_factor; + + /*!\brief Keyframe maximum total boost adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t kf_max_total_boost_factor; + + /*!\brief Golden frame maximum total boost adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t gf_max_total_boost_factor; + + /*!\brief Golden frame maximum boost adjustment factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t gf_frame_max_boost_factor; + + /*!\brief Zero motion power factor. + * + * Rate control parameters, set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t zm_factor; + + /*!\brief Rate-distortion multiplier for inter frames. + * The multiplier is a crucial parameter in the calculation of rate distortion + * cost. It is often related to the qp (qindex) value. + * Rate control parameters, could be set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t rd_mult_inter_qp_fac; + + /*!\brief Rate-distortion multiplier for alt-ref frames. + * The multiplier is a crucial parameter in the calculation of rate distortion + * cost. It is often related to the qp (qindex) value. + * Rate control parameters, could be set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t rd_mult_arf_qp_fac; + + /*!\brief Rate-distortion multiplier for key frames. + * The multiplier is a crucial parameter in the calculation of rate distortion + * cost. It is often related to the qp (qindex) value. + * Rate control parameters, could be set from external experiment results. + * Only when |use_vizier_rc_params| is set to 1, the pass in value will be + * used. Otherwise, the default value is used. + * + */ + vpx_rational_t rd_mult_key_qp_fac; } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */ /*!\brief vp9 svc extra configure parameters @@ -705,6 +852,7 @@ typedef struct vpx_svc_parameters { int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */ int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */ int temporal_layering_mode; /**< Temporal layering mode */ + int loopfilter_ctrl[VPX_MAX_LAYERS]; /**< Loopfilter ctrl for each sl */ } vpx_svc_extra_cfg_t; /*!\brief Initialize an encoder instance diff --git a/third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h b/third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h new file mode 100644 index 000000000000..a193e5595332 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h @@ -0,0 +1,360 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_VPX_VPX_EXT_RATECTRL_H_ +#define VPX_VPX_VPX_EXT_RATECTRL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "./vpx_integer.h" + +/*!\brief Current ABI version number + * + * \internal + * If this file is altered in any way that changes the ABI, this value + * must be bumped. Examples include, but are not limited to, changing + * types, removing or reassigning enums, adding/removing/rearranging + * fields to structures. + */ +#define VPX_EXT_RATECTRL_ABI_VERSION (1) + +/*!\brief Abstract rate control model handler + * + * The encoder will receive the model handler from create_model() defined in + * vpx_rc_funcs_t. + */ +typedef void *vpx_rc_model_t; + +/*!\brief Encode frame decision made by the external rate control model + * + * The encoder will receive the decision from the external rate control model + * through get_encodeframe_decision() defined in vpx_rc_funcs_t. + * + * If max_frame_size = 0, the encoding ignores max frame size limit. + * If max_frame_size = -1, the encoding uses VP9's max frame size as the limit. + * If the encoded frame size is larger than max_frame_size, the frame is + * recoded to meet the size limit, following VP9's recoding principles. + */ +typedef struct vpx_rc_encodeframe_decision { + int q_index; /**< Quantizer step index [0..255]*/ + int max_frame_size; /**< Maximal frame size allowed to encode a frame*/ +} vpx_rc_encodeframe_decision_t; + +/*!\brief Information for the frame to be encoded. + * + * The encoder will send the information to external rate control model through + * get_encodeframe_decision() defined in vpx_rc_funcs_t. + * + */ +typedef struct vpx_rc_encodeframe_info { + /*! + * 0: Key frame + * 1: Inter frame + * 2: Alternate reference frame + * 3: Overlay frame + * 4: Golden frame + */ + int frame_type; + int show_index; /**< display index, starts from zero*/ + int coding_index; /**< coding index, starts from zero*/ + /*! + * index in group of picture, starts from zero. + */ + int gop_index; + int ref_frame_coding_indexes[3]; /**< three reference frames' coding indices*/ + /*! + * The validity of the three reference frames. + * 0: Invalid + * 1: Valid + */ + int ref_frame_valid_list[3]; +} vpx_rc_encodeframe_info_t; + +/*!\brief Frame coding result + * + * The encoder will send the result to the external rate control model through + * update_encodeframe_result() defined in vpx_rc_funcs_t. + */ +typedef struct vpx_rc_encodeframe_result { + int64_t sse; /**< sum of squared error of the reconstructed frame */ + int64_t bit_count; /**< number of bits spent on coding the frame*/ + int64_t pixel_count; /**< number of pixels in YUV planes of the frame*/ + int actual_encoding_qindex; /**< the actual qindex used to encode the frame*/ +} vpx_rc_encodeframe_result_t; + +/*!\brief Status returned by rate control callback functions. + */ +typedef enum vpx_rc_status { + VPX_RC_OK = 0, + VPX_RC_ERROR = 1, +} vpx_rc_status_t; + +/*!\brief First pass frame stats + * This is a mirror of vp9's FIRSTPASS_STATS except that spatial_layer_id is + * omitted + */ +typedef struct vpx_rc_frame_stats { + /*! + * Frame number in display order, if stats are for a single frame. + * No real meaning for a collection of frames. + */ + double frame; + /*! + * Weight assigned to this frame (or total weight for the collection of + * frames) currently based on intra factor and brightness factor. This is used + * to distribute bits between easier and harder frames. + */ + double weight; + /*! + * Intra prediction error. + */ + double intra_error; + /*! + * Best of intra pred error and inter pred error using last frame as ref. + */ + double coded_error; + /*! + * Best of intra pred error and inter pred error using golden frame as ref. + */ + double sr_coded_error; + /*! + * Estimate the noise energy of the current frame. + */ + double frame_noise_energy; + /*! + * Percentage of blocks with inter pred error < intra pred error. + */ + double pcnt_inter; + /*! + * Percentage of blocks using (inter prediction and) non-zero motion vectors. + */ + double pcnt_motion; + /*! + * Percentage of blocks where golden frame was better than last or intra: + * inter pred error using golden frame < inter pred error using last frame and + * inter pred error using golden frame < intra pred error + */ + double pcnt_second_ref; + /*! + * Percentage of blocks where intra and inter prediction errors were very + * close. + */ + double pcnt_neutral; + /*! + * Percentage of blocks that have intra error < inter error and inter error < + * LOW_I_THRESH + * - bit_depth 8: LOW_I_THRESH = 24000 + * - bit_depth 10: LOW_I_THRESH = 24000 << 4 + * - bit_depth 12: LOW_I_THRESH = 24000 << 8 + */ + double pcnt_intra_low; + /*! + * Percentage of blocks that have intra error < inter error and intra error < + * LOW_I_THRESH but inter error >= LOW_I_THRESH LOW_I_THRESH + * - bit_depth 8: LOW_I_THRESH = 24000 + * - bit_depth 10: LOW_I_THRESH = 24000 << 4 + * - bit_depth 12: LOW_I_THRESH = 24000 << 8 + */ + double pcnt_intra_high; + /*! + * Percentage of blocks that have almost no intra error residual + * (i.e. are in effect completely flat and untextured in the intra + * domain). In natural videos this is uncommon, but it is much more + * common in animations, graphics and screen content, so may be used + * as a signal to detect these types of content. + */ + double intra_skip_pct; + /*! + * Percentage of blocks that have intra error < SMOOTH_INTRA_THRESH + * - bit_depth 8: SMOOTH_INTRA_THRESH = 4000 + * - bit_depth 10: SMOOTH_INTRA_THRESH = 4000 << 4 + * - bit_depth 12: SMOOTH_INTRA_THRESH = 4000 << 8 + */ + double intra_smooth_pct; + /*! + * Image mask rows top and bottom. + */ + double inactive_zone_rows; + /*! + * Image mask columns at left and right edges. + */ + double inactive_zone_cols; + /*! + * Mean of row motion vectors. + */ + double MVr; + /*! + * Mean of absolute value of row motion vectors. + */ + double mvr_abs; + /*! + * Mean of column motion vectors. + */ + double MVc; + /*! + * Mean of absolute value of column motion vectors. + */ + double mvc_abs; + /*! + * Variance of row motion vectors. + */ + double MVrv; + /*! + * Variance of column motion vectors. + */ + double MVcv; + /*! + * Value in range [-1,1] indicating fraction of row and column motion vectors + * that point inwards (negative MV value) or outwards (positive MV value). + * For example, value of 1 indicates, all row/column MVs are inwards. + */ + double mv_in_out_count; + /*! + * Duration of the frame / collection of frames. + */ + double duration; + /*! + * 1.0 if stats are for a single frame, or + * number of frames whose stats are accumulated. + */ + double count; +} vpx_rc_frame_stats_t; + +/*!\brief Collection of first pass frame stats + */ +typedef struct vpx_rc_firstpass_stats { + /*! + * Pointer to first pass frame stats. + * The pointed array of vpx_rc_frame_stats_t should have length equal to + * number of show frames in the video. + */ + vpx_rc_frame_stats_t *frame_stats; + /*! + * Number of show frames in the video. + */ + int num_frames; +} vpx_rc_firstpass_stats_t; + +/*!\brief Encode config sent to external rate control model + */ +typedef struct vpx_rc_config { + int frame_width; /**< frame width */ + int frame_height; /**< frame height */ + int show_frame_count; /**< number of visible frames in the video */ + /*! + * Target bitrate in kilobytes per second + */ + int target_bitrate_kbps; + int frame_rate_num; /**< numerator of frame rate */ + int frame_rate_den; /**< denominator of frame rate */ +} vpx_rc_config_t; + +/*!\brief Create an external rate control model callback prototype + * + * This callback is invoked by the encoder to create an external rate control + * model. + * + * \param[in] priv Callback's private data + * \param[in] ratectrl_config Pointer to vpx_rc_config_t + * \param[out] rate_ctrl_model_pt Pointer to vpx_rc_model_t + */ +typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)( + void *priv, const vpx_rc_config_t *ratectrl_config, + vpx_rc_model_t *rate_ctrl_model_pt); + +/*!\brief Send first pass stats to the external rate control model callback + * prototype + * + * This callback is invoked by the encoder to send first pass stats to the + * external rate control model. + * + * \param[in] rate_ctrl_model rate control model + * \param[in] first_pass_stats first pass stats + */ +typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_firstpass_stats_t *first_pass_stats); + +/*!\brief Receive encode frame decision callback prototype + * + * This callback is invoked by the encoder to receive encode frame decision from + * the external rate control model. + * + * \param[in] rate_ctrl_model rate control model + * \param[in] encode_frame_info information of the coding frame + * \param[out] frame_decision encode decision of the coding frame + */ +typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_encodeframe_info_t *encode_frame_info, + vpx_rc_encodeframe_decision_t *frame_decision); + +/*!\brief Update encode frame result callback prototype + * + * This callback is invoked by the encoder to update encode frame result to the + * external rate control model. + * + * \param[in] rate_ctrl_model rate control model + * \param[out] encode_frame_result encode result of the coding frame + */ +typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)( + vpx_rc_model_t rate_ctrl_model, + const vpx_rc_encodeframe_result_t *encode_frame_result); + +/*!\brief Delete the external rate control model callback prototype + * + * This callback is invoked by the encoder to delete the external rate control + * model. + * + * \param[in] rate_ctrl_model rate control model + */ +typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)( + vpx_rc_model_t rate_ctrl_model); + +/*!\brief Callback function set for external rate control. + * + * The user can enable external rate control by registering + * a set of callback functions with the codec control flag + * VP9E_SET_EXTERNAL_RATE_CONTROL. + */ +typedef struct vpx_rc_funcs { + /*! + * Create an external rate control model. + */ + vpx_rc_create_model_cb_fn_t create_model; + /*! + * Send first pass stats to the external rate control model. + */ + vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats; + /*! + * Get encodeframe decision from the external rate control model. + */ + vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision; + /*! + * Update encodeframe result to the external rate control model. + */ + vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result; + /*! + * Delete the external rate control model. + */ + vpx_rc_delete_model_cb_fn_t delete_model; + /*! + * Private data for the external rate control model. + */ + void *priv; +} vpx_rc_funcs_t; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // VPX_VPX_VPX_EXT_RATECTRL_H_ diff --git a/third_party/libvpx/vpx/vpx_frame_buffer.h b/third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h similarity index 100% rename from third_party/libvpx/vpx/vpx_frame_buffer.h rename to third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h diff --git a/third_party/libvpx/vpx/vpx_image.h b/third_party/libvpx/source/libvpx/vpx/vpx_image.h similarity index 97% rename from third_party/libvpx/vpx/vpx_image.h rename to third_party/libvpx/source/libvpx/vpx/vpx_image.h index bc23be50c58a..1adc9b9d9eb6 100644 --- a/third_party/libvpx/vpx/vpx_image.h +++ b/third_party/libvpx/source/libvpx/vpx/vpx_image.h @@ -171,7 +171,8 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, /*!\brief Set the rectangle identifying the displayed portion of the image * * Updates the displayed rectangle (aka viewport) on the image surface to - * match the specified coordinates and size. + * match the specified coordinates and size. Specifically, sets img->d_w, + * img->d_h, and elements of the img->planes[] array. * * \param[in] img Image descriptor * \param[in] x leftmost column @@ -179,7 +180,7 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, * \param[in] w width * \param[in] h height * - * \return 0 if the requested rectangle is valid, nonzero otherwise. + * \return 0 if the requested rectangle is valid, nonzero (-1) otherwise. */ int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y, unsigned int w, unsigned int h); diff --git a/third_party/libvpx/vpx/vpx_integer.h b/third_party/libvpx/source/libvpx/vpx/vpx_integer.h similarity index 100% rename from third_party/libvpx/vpx/vpx_integer.h rename to third_party/libvpx/source/libvpx/vpx/vpx_integer.h diff --git a/third_party/libvpx/vpx_dsp/add_noise.c b/third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c similarity index 100% rename from third_party/libvpx/vpx_dsp/add_noise.c rename to third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c diff --git a/third_party/libvpx/vpx_dsp/arm/avg_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c similarity index 96% rename from third_party/libvpx/vpx_dsp/arm/avg_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c index fa7dd0960051..8e57bdaa5008 100644 --- a/third_party/libvpx/vpx_dsp/arm/avg_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c @@ -22,15 +22,13 @@ uint32_t vpx_avg_4x4_neon(const uint8_t *a, int a_stride) { const uint8x16_t b = load_unaligned_u8q(a, a_stride); const uint16x8_t c = vaddl_u8(vget_low_u8(b), vget_high_u8(b)); - const uint32x2_t d = horizontal_add_uint16x8(c); - return vget_lane_u32(vrshr_n_u32(d, 4), 0); + return (horizontal_add_uint16x8(c) + (1 << 3)) >> 4; } uint32_t vpx_avg_8x8_neon(const uint8_t *a, int a_stride) { int i; uint8x8_t b, c; uint16x8_t sum; - uint32x2_t d; b = vld1_u8(a); a += a_stride; c = vld1_u8(a); @@ -43,9 +41,7 @@ uint32_t vpx_avg_8x8_neon(const uint8_t *a, int a_stride) { sum = vaddw_u8(sum, d); } - d = horizontal_add_uint16x8(sum); - - return vget_lane_u32(vrshr_n_u32(d, 6), 0); + return (horizontal_add_uint16x8(sum) + (1 << 5)) >> 6; } // coeff: 16 bits, dynamic range [-32640, 32640]. @@ -139,8 +135,7 @@ int16_t vpx_int_pro_col_neon(uint8_t const *ref, const int width) { ref += 16; } - return vget_lane_s16(vreinterpret_s16_u32(horizontal_add_uint16x8(vec_sum)), - 0); + return (int16_t)horizontal_add_uint16x8(vec_sum); } // ref, src = [0, 510] - max diff = 16-bits diff --git a/third_party/libvpx/vpx_dsp/arm/avg_pred_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/avg_pred_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/deblock_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/deblock_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/fdct16x16_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/fdct16x16_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/fdct32x32_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/fdct32x32_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/fdct_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/fdct_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/fdct_partial_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c similarity index 76% rename from third_party/libvpx/vpx_dsp/arm/fdct_partial_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c index e73de41d775f..0a1cdca41dcd 100644 --- a/third_party/libvpx/vpx_dsp/arm/fdct_partial_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c @@ -15,19 +15,10 @@ #include "vpx_dsp/arm/mem_neon.h" #include "vpx_dsp/arm/sum_neon.h" -static INLINE tran_low_t get_lane(const int32x2_t a) { -#if CONFIG_VP9_HIGHBITDEPTH - return vget_lane_s32(a, 0); -#else - return vget_lane_s16(vreinterpret_s16_s32(a), 0); -#endif // CONFIG_VP9_HIGHBITDETPH -} - void vpx_fdct4x4_1_neon(const int16_t *input, tran_low_t *output, int stride) { int16x4_t a0, a1, a2, a3; int16x8_t b0, b1; int16x8_t c; - int32x2_t d; a0 = vld1_s16(input); input += stride; @@ -42,9 +33,7 @@ void vpx_fdct4x4_1_neon(const int16_t *input, tran_low_t *output, int stride) { c = vaddq_s16(b0, b1); - d = horizontal_add_int16x8(c); - - output[0] = get_lane(vshl_n_s32(d, 1)); + output[0] = (tran_low_t)(horizontal_add_int16x8(c) << 1); output[1] = 0; } @@ -57,7 +46,7 @@ void vpx_fdct8x8_1_neon(const int16_t *input, tran_low_t *output, int stride) { sum = vaddq_s16(sum, input_00); } - output[0] = get_lane(horizontal_add_int16x8(sum)); + output[0] = (tran_low_t)horizontal_add_int16x8(sum); output[1] = 0; } @@ -66,7 +55,7 @@ void vpx_fdct16x16_1_neon(const int16_t *input, tran_low_t *output, int r; int16x8_t left = vld1q_s16(input); int16x8_t right = vld1q_s16(input + 8); - int32x2_t sum; + int32_t sum; input += stride; for (r = 1; r < 16; ++r) { @@ -77,9 +66,9 @@ void vpx_fdct16x16_1_neon(const int16_t *input, tran_low_t *output, right = vaddq_s16(right, b); } - sum = vadd_s32(horizontal_add_int16x8(left), horizontal_add_int16x8(right)); + sum = horizontal_add_int16x8(left) + horizontal_add_int16x8(right); - output[0] = get_lane(vshr_n_s32(sum, 1)); + output[0] = (tran_low_t)(sum >> 1); output[1] = 0; } @@ -90,7 +79,7 @@ void vpx_fdct32x32_1_neon(const int16_t *input, tran_low_t *output, int16x8_t a1 = vld1q_s16(input + 8); int16x8_t a2 = vld1q_s16(input + 16); int16x8_t a3 = vld1q_s16(input + 24); - int32x2_t sum; + int32_t sum; input += stride; for (r = 1; r < 32; ++r) { @@ -105,9 +94,10 @@ void vpx_fdct32x32_1_neon(const int16_t *input, tran_low_t *output, a3 = vaddq_s16(a3, b3); } - sum = vadd_s32(horizontal_add_int16x8(a0), horizontal_add_int16x8(a1)); - sum = vadd_s32(sum, horizontal_add_int16x8(a2)); - sum = vadd_s32(sum, horizontal_add_int16x8(a3)); - output[0] = get_lane(vshr_n_s32(sum, 3)); + sum = horizontal_add_int16x8(a0); + sum += horizontal_add_int16x8(a1); + sum += horizontal_add_int16x8(a2); + sum += horizontal_add_int16x8(a3); + output[0] = (tran_low_t)(sum >> 3); output[1] = 0; } diff --git a/third_party/libvpx/vpx_dsp/arm/fwd_txfm_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/fwd_txfm_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/fwd_txfm_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/fwd_txfm_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/hadamard_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/hadamard_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_idct_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct_neon.h similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_idct_neon.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct_neon.h diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c similarity index 98% rename from third_party/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c index 5530c6425b27..8d6e8acc4c5f 100644 --- a/third_party/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c @@ -661,6 +661,17 @@ void vpx_highbd_lpf_vertical_8_dual_neon( vpx_highbd_lpf_vertical_8_neon(s + 8 * p, p, blimit1, limit1, thresh1, bd); } +// Quiet warnings of the form: 'vpx_dsp/arm/highbd_loopfilter_neon.c|675 col 67| +// warning: 'oq1' may be used uninitialized in this function +// [-Wmaybe-uninitialized]', for oq1-op1. Without reworking the code or adding +// an additional branch this warning cannot be silenced otherwise. The +// loopfilter is only called when needed for a block so these output pixels +// will be set. +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + static void lpf_horizontal_16_kernel(uint16_t *s, int p, const uint16x8_t blimit_vec, const uint16x8_t limit_vec, @@ -723,6 +734,10 @@ static void lpf_vertical_16_kernel(uint16_t *s, int p, } } +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + void vpx_highbd_lpf_horizontal_16_neon(uint16_t *s, int p, const uint8_t *blimit, const uint8_t *limit, diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct16x16_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct16x16_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct32x32_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct32x32_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct4x4_add_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct4x4_add_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/idct4x4_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct4x4_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct8x8_add_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct8x8_add_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/idct_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/idct_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/idct_neon.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h diff --git a/third_party/libvpx/vpx_dsp/arm/intrapred_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/intrapred_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/intrapred_neon_asm.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon_asm.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/intrapred_neon_asm.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon_asm.asm diff --git a/third_party/libvpx/vpx_dsp/arm/loopfilter_16_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_16_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/loopfilter_16_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_16_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/loopfilter_4_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_4_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/loopfilter_4_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_4_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/loopfilter_8_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_8_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/loopfilter_8_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_8_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/loopfilter_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c similarity index 98% rename from third_party/libvpx/vpx_dsp/arm/loopfilter_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c index 7419cea022de..c54e5882394d 100644 --- a/third_party/libvpx/vpx_dsp/arm/loopfilter_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c @@ -975,6 +975,17 @@ FUN_LPF_16_KERNEL(_, 8) // lpf_16_kernel FUN_LPF_16_KERNEL(_dual_, 16) // lpf_16_dual_kernel #undef FUN_LPF_16_KERNEL +// Quiet warnings of the form: 'vpx_dsp/arm/loopfilter_neon.c|981 col 42| +// warning: 'oq1' may be used uninitialized in this function +// [-Wmaybe-uninitialized]', for oq1-op1. Without reworking the code or adding +// an additional branch this warning cannot be silenced otherwise. The +// loopfilter is only called when needed for a block so these output pixels +// will be set. +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + void vpx_lpf_horizontal_16_neon(uint8_t *s, int p, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh) { uint8x8_t p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7, op6, @@ -1090,3 +1101,7 @@ void vpx_lpf_vertical_16_dual_neon(uint8_t *s, int p, const uint8_t *blimit, vget_high_u8(oq0), vget_high_u8(oq1)); } } + +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__) +#pragma GCC diagnostic pop +#endif diff --git a/third_party/libvpx/vpx_dsp/arm/mem_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h similarity index 83% rename from third_party/libvpx/vpx_dsp/arm/mem_neon.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h index 943865b3c280..50aaa94fe091 100644 --- a/third_party/libvpx/vpx_dsp/arm/mem_neon.h +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h @@ -19,6 +19,24 @@ #include "vpx/vpx_integer.h" #include "vpx_dsp/vpx_dsp_common.h" +// Support for these xN intrinsics is lacking in older versions of GCC. +#if defined(__GNUC__) && !defined(__clang__) +#if __GNUC__ < 8 || defined(__arm__) +static INLINE uint8x16x2_t vld1q_u8_x2(uint8_t const *ptr) { + uint8x16x2_t res = { { vld1q_u8(ptr + 0 * 16), vld1q_u8(ptr + 1 * 16) } }; + return res; +} +#endif + +#if __GNUC__ < 9 || defined(__arm__) +static INLINE uint8x16x3_t vld1q_u8_x3(uint8_t const *ptr) { + uint8x16x3_t res = { { vld1q_u8(ptr + 0 * 16), vld1q_u8(ptr + 1 * 16), + vld1q_u8(ptr + 2 * 16) } }; + return res; +} +#endif +#endif + static INLINE int16x4_t create_s16x4_neon(const int16_t c0, const int16_t c1, const int16_t c2, const int16_t c3) { return vcreate_s16((uint16_t)c0 | ((uint32_t)c1 << 16) | @@ -95,7 +113,8 @@ static INLINE void uint32_to_mem(uint8_t *buf, uint32_t a) { } // Load 2 sets of 4 bytes when alignment is not guaranteed. -static INLINE uint8x8_t load_unaligned_u8(const uint8_t *buf, int stride) { +static INLINE uint8x8_t load_unaligned_u8(const uint8_t *buf, + ptrdiff_t stride) { uint32_t a; uint32x2_t a_u32 = vdup_n_u32(0); if (stride == 4) return vld1_u8(buf); @@ -108,7 +127,7 @@ static INLINE uint8x8_t load_unaligned_u8(const uint8_t *buf, int stride) { } // Store 2 sets of 4 bytes when alignment is not guaranteed. -static INLINE void store_unaligned_u8(uint8_t *buf, int stride, +static INLINE void store_unaligned_u8(uint8_t *buf, ptrdiff_t stride, const uint8x8_t a) { const uint32x2_t a_u32 = vreinterpret_u32_u8(a); if (stride == 4) { @@ -121,7 +140,8 @@ static INLINE void store_unaligned_u8(uint8_t *buf, int stride, } // Load 4 sets of 4 bytes when alignment is not guaranteed. -static INLINE uint8x16_t load_unaligned_u8q(const uint8_t *buf, int stride) { +static INLINE uint8x16_t load_unaligned_u8q(const uint8_t *buf, + ptrdiff_t stride) { uint32_t a; uint32x4_t a_u32 = vdupq_n_u32(0); if (stride == 4) return vld1q_u8(buf); @@ -141,7 +161,7 @@ static INLINE uint8x16_t load_unaligned_u8q(const uint8_t *buf, int stride) { } // Store 4 sets of 4 bytes when alignment is not guaranteed. -static INLINE void store_unaligned_u8q(uint8_t *buf, int stride, +static INLINE void store_unaligned_u8q(uint8_t *buf, ptrdiff_t stride, const uint8x16_t a) { const uint32x4_t a_u32 = vreinterpretq_u32_u8(a); if (stride == 4) { @@ -158,7 +178,7 @@ static INLINE void store_unaligned_u8q(uint8_t *buf, int stride, } // Load 2 sets of 4 bytes when alignment is guaranteed. -static INLINE uint8x8_t load_u8(const uint8_t *buf, int stride) { +static INLINE uint8x8_t load_u8(const uint8_t *buf, ptrdiff_t stride) { uint32x2_t a = vdup_n_u32(0); assert(!((intptr_t)buf % sizeof(uint32_t))); @@ -171,7 +191,7 @@ static INLINE uint8x8_t load_u8(const uint8_t *buf, int stride) { } // Store 2 sets of 4 bytes when alignment is guaranteed. -static INLINE void store_u8(uint8_t *buf, int stride, const uint8x8_t a) { +static INLINE void store_u8(uint8_t *buf, ptrdiff_t stride, const uint8x8_t a) { uint32x2_t a_u32 = vreinterpret_u32_u8(a); assert(!((intptr_t)buf % sizeof(uint32_t))); diff --git a/third_party/libvpx/vpx_dsp/arm/quantize_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/quantize_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/sad4d_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c similarity index 61% rename from third_party/libvpx/vpx_dsp/arm/sad4d_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c index 06443c69956f..5c7a0fcaf009 100644 --- a/third_party/libvpx/vpx_dsp/arm/sad4d_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c @@ -34,7 +34,9 @@ static INLINE void sad4x_4d(const uint8_t *const src_ptr, const int src_stride, uint32_t *const res) { int i; uint16x8_t abs[2] = { vdupq_n_u16(0), vdupq_n_u16(0) }; +#if !defined(__aarch64__) uint16x4_t a[2]; +#endif uint32x4_t r; assert(!((intptr_t)src_ptr % sizeof(uint32_t))); @@ -51,9 +53,14 @@ static INLINE void sad4x_4d(const uint8_t *const src_ptr, const int src_stride, abs[1] = vabal_u8(abs[1], s, ref23); } +#if defined(__aarch64__) + abs[0] = vpaddq_u16(abs[0], abs[1]); + r = vpaddlq_u16(abs[0]); +#else a[0] = vpadd_u16(vget_low_u16(abs[0]), vget_high_u16(abs[0])); a[1] = vpadd_u16(vget_low_u16(abs[1]), vget_high_u16(abs[1])); r = vpaddlq_u16(vcombine_u16(a[0], a[1])); +#endif vst1q_u32(res, r); } @@ -74,6 +81,12 @@ void vpx_sad4x8x4d_neon(const uint8_t *src_ptr, int src_stride, // Can handle 512 pixels' sad sum (such as 16x32 or 32x16) static INLINE void sad_512_pel_final_neon(const uint16x8_t *sum /*[4]*/, uint32_t *const res) { +#if defined(__aarch64__) + const uint16x8_t a0 = vpaddq_u16(sum[0], sum[1]); + const uint16x8_t a1 = vpaddq_u16(sum[2], sum[3]); + const uint16x8_t b0 = vpaddq_u16(a0, a1); + const uint32x4_t r = vpaddlq_u16(b0); +#else const uint16x4_t a0 = vadd_u16(vget_low_u16(sum[0]), vget_high_u16(sum[0])); const uint16x4_t a1 = vadd_u16(vget_low_u16(sum[1]), vget_high_u16(sum[1])); const uint16x4_t a2 = vadd_u16(vget_low_u16(sum[2]), vget_high_u16(sum[2])); @@ -81,12 +94,23 @@ static INLINE void sad_512_pel_final_neon(const uint16x8_t *sum /*[4]*/, const uint16x4_t b0 = vpadd_u16(a0, a1); const uint16x4_t b1 = vpadd_u16(a2, a3); const uint32x4_t r = vpaddlq_u16(vcombine_u16(b0, b1)); +#endif vst1q_u32(res, r); } +#if defined(__arm__) || !defined(__ARM_FEATURE_DOTPROD) + // Can handle 1024 pixels' sad sum (such as 32x32) static INLINE void sad_1024_pel_final_neon(const uint16x8_t *sum /*[4]*/, uint32_t *const res) { +#if defined(__aarch64__) + const uint16x8_t a0 = vpaddq_u16(sum[0], sum[1]); + const uint16x8_t a1 = vpaddq_u16(sum[2], sum[3]); + const uint32x4_t b0 = vpaddlq_u16(a0); + const uint32x4_t b1 = vpaddlq_u16(a1); + const uint32x4_t r = vpaddq_u32(b0, b1); + vst1q_u32(res, r); +#else const uint16x4_t a0 = vpadd_u16(vget_low_u16(sum[0]), vget_high_u16(sum[0])); const uint16x4_t a1 = vpadd_u16(vget_low_u16(sum[1]), vget_high_u16(sum[1])); const uint16x4_t a2 = vpadd_u16(vget_low_u16(sum[2]), vget_high_u16(sum[2])); @@ -96,11 +120,22 @@ static INLINE void sad_1024_pel_final_neon(const uint16x8_t *sum /*[4]*/, const uint32x2_t c0 = vpadd_u32(vget_low_u32(b0), vget_high_u32(b0)); const uint32x2_t c1 = vpadd_u32(vget_low_u32(b1), vget_high_u32(b1)); vst1q_u32(res, vcombine_u32(c0, c1)); +#endif } // Can handle 2048 pixels' sad sum (such as 32x64 or 64x32) static INLINE void sad_2048_pel_final_neon(const uint16x8_t *sum /*[4]*/, uint32_t *const res) { +#if defined(__aarch64__) + const uint32x4_t a0 = vpaddlq_u16(sum[0]); + const uint32x4_t a1 = vpaddlq_u16(sum[1]); + const uint32x4_t a2 = vpaddlq_u16(sum[2]); + const uint32x4_t a3 = vpaddlq_u16(sum[3]); + const uint32x4_t b0 = vpaddq_u32(a0, a1); + const uint32x4_t b1 = vpaddq_u32(a2, a3); + const uint32x4_t r = vpaddq_u32(b0, b1); + vst1q_u32(res, r); +#else const uint32x4_t a0 = vpaddlq_u16(sum[0]); const uint32x4_t a1 = vpaddlq_u16(sum[1]); const uint32x4_t a2 = vpaddlq_u16(sum[2]); @@ -112,11 +147,30 @@ static INLINE void sad_2048_pel_final_neon(const uint16x8_t *sum /*[4]*/, const uint32x2_t c0 = vpadd_u32(b0, b1); const uint32x2_t c1 = vpadd_u32(b2, b3); vst1q_u32(res, vcombine_u32(c0, c1)); +#endif } // Can handle 4096 pixels' sad sum (such as 64x64) static INLINE void sad_4096_pel_final_neon(const uint16x8_t *sum /*[8]*/, uint32_t *const res) { +#if defined(__aarch64__) + const uint32x4_t a0 = vpaddlq_u16(sum[0]); + const uint32x4_t a1 = vpaddlq_u16(sum[1]); + const uint32x4_t a2 = vpaddlq_u16(sum[2]); + const uint32x4_t a3 = vpaddlq_u16(sum[3]); + const uint32x4_t a4 = vpaddlq_u16(sum[4]); + const uint32x4_t a5 = vpaddlq_u16(sum[5]); + const uint32x4_t a6 = vpaddlq_u16(sum[6]); + const uint32x4_t a7 = vpaddlq_u16(sum[7]); + const uint32x4_t b0 = vaddq_u32(a0, a1); + const uint32x4_t b1 = vaddq_u32(a2, a3); + const uint32x4_t b2 = vaddq_u32(a4, a5); + const uint32x4_t b3 = vaddq_u32(a6, a7); + const uint32x4_t c0 = vpaddq_u32(b0, b1); + const uint32x4_t c1 = vpaddq_u32(b2, b3); + const uint32x4_t r = vpaddq_u32(c0, c1); + vst1q_u32(res, r); +#else const uint32x4_t a0 = vpaddlq_u16(sum[0]); const uint32x4_t a1 = vpaddlq_u16(sum[1]); const uint32x4_t a2 = vpaddlq_u16(sum[2]); @@ -136,8 +190,11 @@ static INLINE void sad_4096_pel_final_neon(const uint16x8_t *sum /*[8]*/, const uint32x2_t d0 = vpadd_u32(c0, c1); const uint32x2_t d1 = vpadd_u32(c2, c3); vst1q_u32(res, vcombine_u32(d0, d1)); +#endif } +#endif + static INLINE void sad8x_4d(const uint8_t *src_ptr, int src_stride, const uint8_t *const ref_array[4], int ref_stride, uint32_t *res, const int height) { @@ -180,6 +237,41 @@ void vpx_sad8x16x4d_neon(const uint8_t *src_ptr, int src_stride, //////////////////////////////////////////////////////////////////////////////// +#if defined(__aarch64__) && defined(__ARM_FEATURE_DOTPROD) && \ + (__ARM_FEATURE_DOTPROD == 1) + +static INLINE void sad16_neon(const uint8_t *ref_ptr, const uint8x16_t src_ptr, + uint32x4_t *const sum) { + const uint8x16_t r = vld1q_u8(ref_ptr); + const uint8x16_t diff = vabdq_u8(src_ptr, r); + *sum = vdotq_u32(*sum, diff, vdupq_n_u8(1)); +} + +static INLINE void sad16x_4d(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res, const int height) { + int i; + uint32x4_t r0, r1; + const uint8_t *ref_loop[4] = { ref_array[0], ref_array[1], ref_array[2], + ref_array[3] }; + uint32x4_t sum[4] = { vdupq_n_u32(0), vdupq_n_u32(0), vdupq_n_u32(0), + vdupq_n_u32(0) }; + + for (i = 0; i < height; ++i) { + const uint8x16_t s = vld1q_u8(src_ptr + i * src_stride); + sad16_neon(ref_loop[0] + i * ref_stride, s, &sum[0]); + sad16_neon(ref_loop[1] + i * ref_stride, s, &sum[1]); + sad16_neon(ref_loop[2] + i * ref_stride, s, &sum[2]); + sad16_neon(ref_loop[3] + i * ref_stride, s, &sum[3]); + } + + r0 = vpaddq_u32(sum[0], sum[1]); + r1 = vpaddq_u32(sum[2], sum[3]); + vst1q_u32(res, vpaddq_u32(r0, r1)); +} + +#else + static INLINE void sad16_neon(const uint8_t *ref_ptr, const uint8x16_t src_ptr, uint16x8_t *const sum) { const uint8x16_t r = vld1q_u8(ref_ptr); @@ -190,7 +282,7 @@ static INLINE void sad16_neon(const uint8_t *ref_ptr, const uint8x16_t src_ptr, static INLINE void sad16x_4d(const uint8_t *src_ptr, int src_stride, const uint8_t *const ref_array[4], int ref_stride, uint32_t *res, const int height) { - int i, j; + int i; const uint8_t *ref_loop[4] = { ref_array[0], ref_array[1], ref_array[2], ref_array[3] }; uint16x8_t sum[4] = { vdupq_n_u16(0), vdupq_n_u16(0), vdupq_n_u16(0), @@ -199,15 +291,22 @@ static INLINE void sad16x_4d(const uint8_t *src_ptr, int src_stride, for (i = 0; i < height; ++i) { const uint8x16_t s = vld1q_u8(src_ptr); src_ptr += src_stride; - for (j = 0; j < 4; ++j) { - sad16_neon(ref_loop[j], s, &sum[j]); - ref_loop[j] += ref_stride; - } + /* Manual unrolling here stops the compiler from getting confused. */ + sad16_neon(ref_loop[0], s, &sum[0]); + ref_loop[0] += ref_stride; + sad16_neon(ref_loop[1], s, &sum[1]); + ref_loop[1] += ref_stride; + sad16_neon(ref_loop[2], s, &sum[2]); + ref_loop[2] += ref_stride; + sad16_neon(ref_loop[3], s, &sum[3]); + ref_loop[3] += ref_stride; } sad_512_pel_final_neon(sum, res); } +#endif + void vpx_sad16x8x4d_neon(const uint8_t *src_ptr, int src_stride, const uint8_t *const ref_array[4], int ref_stride, uint32_t *res) { @@ -228,6 +327,67 @@ void vpx_sad16x32x4d_neon(const uint8_t *src_ptr, int src_stride, //////////////////////////////////////////////////////////////////////////////// +#if defined(__aarch64__) && defined(__ARM_FEATURE_DOTPROD) && \ + (__ARM_FEATURE_DOTPROD == 1) + +static INLINE void sad32x_4d(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res, const int height) { + int i; + uint32x4_t r0, r1; + const uint8_t *ref_loop[4] = { ref_array[0], ref_array[1], ref_array[2], + ref_array[3] }; + + uint32x4_t sum[4] = { vdupq_n_u32(0), vdupq_n_u32(0), vdupq_n_u32(0), + vdupq_n_u32(0) }; + + for (i = 0; i < height; ++i) { + uint8x16_t s; + + s = vld1q_u8(src_ptr + 0 * 16); + sad16_neon(ref_loop[0] + 0 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 0 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 0 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 0 * 16, s, &sum[3]); + + s = vld1q_u8(src_ptr + 1 * 16); + sad16_neon(ref_loop[0] + 1 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 1 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 1 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 1 * 16, s, &sum[3]); + + src_ptr += src_stride; + ref_loop[0] += ref_stride; + ref_loop[1] += ref_stride; + ref_loop[2] += ref_stride; + ref_loop[3] += ref_stride; + } + + r0 = vpaddq_u32(sum[0], sum[1]); + r1 = vpaddq_u32(sum[2], sum[3]); + vst1q_u32(res, vpaddq_u32(r0, r1)); +} + +void vpx_sad32x16x4d_neon(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res) { + sad32x_4d(src_ptr, src_stride, ref_array, ref_stride, res, 16); +} + +void vpx_sad32x32x4d_neon(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res) { + sad32x_4d(src_ptr, src_stride, ref_array, ref_stride, res, 32); +} + +void vpx_sad32x64x4d_neon(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res) { + sad32x_4d(src_ptr, src_stride, ref_array, ref_stride, res, 64); +} + +#else + static INLINE void sad32x_4d(const uint8_t *src_ptr, int src_stride, const uint8_t *const ref_array[4], int ref_stride, const int height, uint16x8_t *const sum) { @@ -284,8 +444,118 @@ void vpx_sad32x64x4d_neon(const uint8_t *src_ptr, int src_stride, sad_2048_pel_final_neon(sum, res); } +#endif + //////////////////////////////////////////////////////////////////////////////// +#if defined(__aarch64__) && defined(__ARM_FEATURE_DOTPROD) && \ + (__ARM_FEATURE_DOTPROD == 1) + +void vpx_sad64x32x4d_neon(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res) { + int i; + uint32x4_t r0, r1; + const uint8_t *ref_loop[4] = { ref_array[0], ref_array[1], ref_array[2], + ref_array[3] }; + uint32x4_t sum[4] = { vdupq_n_u32(0), vdupq_n_u32(0), vdupq_n_u32(0), + vdupq_n_u32(0) }; + + for (i = 0; i < 32; ++i) { + uint8x16_t s; + + s = vld1q_u8(src_ptr + 0 * 16); + sad16_neon(ref_loop[0] + 0 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 0 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 0 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 0 * 16, s, &sum[3]); + + s = vld1q_u8(src_ptr + 1 * 16); + sad16_neon(ref_loop[0] + 1 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 1 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 1 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 1 * 16, s, &sum[3]); + + s = vld1q_u8(src_ptr + 2 * 16); + sad16_neon(ref_loop[0] + 2 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 2 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 2 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 2 * 16, s, &sum[3]); + + s = vld1q_u8(src_ptr + 3 * 16); + sad16_neon(ref_loop[0] + 3 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 3 * 16, s, &sum[1]); + sad16_neon(ref_loop[2] + 3 * 16, s, &sum[2]); + sad16_neon(ref_loop[3] + 3 * 16, s, &sum[3]); + + src_ptr += src_stride; + ref_loop[0] += ref_stride; + ref_loop[1] += ref_stride; + ref_loop[2] += ref_stride; + ref_loop[3] += ref_stride; + } + + r0 = vpaddq_u32(sum[0], sum[1]); + r1 = vpaddq_u32(sum[2], sum[3]); + vst1q_u32(res, vpaddq_u32(r0, r1)); +} + +void vpx_sad64x64x4d_neon(const uint8_t *src_ptr, int src_stride, + const uint8_t *const ref_array[4], int ref_stride, + uint32_t *res) { + int i; + uint32x4_t r0, r1, r2, r3; + const uint8_t *ref_loop[4] = { ref_array[0], ref_array[1], ref_array[2], + ref_array[3] }; + uint32x4_t sum[8] = { vdupq_n_u32(0), vdupq_n_u32(0), vdupq_n_u32(0), + vdupq_n_u32(0), vdupq_n_u32(0), vdupq_n_u32(0), + vdupq_n_u32(0), vdupq_n_u32(0) }; + + for (i = 0; i < 64; ++i) { + uint8x16_t s; + + s = vld1q_u8(src_ptr + 0 * 16); + sad16_neon(ref_loop[0] + 0 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 0 * 16, s, &sum[2]); + sad16_neon(ref_loop[2] + 0 * 16, s, &sum[4]); + sad16_neon(ref_loop[3] + 0 * 16, s, &sum[6]); + + s = vld1q_u8(src_ptr + 1 * 16); + sad16_neon(ref_loop[0] + 1 * 16, s, &sum[0]); + sad16_neon(ref_loop[1] + 1 * 16, s, &sum[2]); + sad16_neon(ref_loop[2] + 1 * 16, s, &sum[4]); + sad16_neon(ref_loop[3] + 1 * 16, s, &sum[6]); + + s = vld1q_u8(src_ptr + 2 * 16); + sad16_neon(ref_loop[0] + 2 * 16, s, &sum[1]); + sad16_neon(ref_loop[1] + 2 * 16, s, &sum[3]); + sad16_neon(ref_loop[2] + 2 * 16, s, &sum[5]); + sad16_neon(ref_loop[3] + 2 * 16, s, &sum[7]); + + s = vld1q_u8(src_ptr + 3 * 16); + sad16_neon(ref_loop[0] + 3 * 16, s, &sum[1]); + sad16_neon(ref_loop[1] + 3 * 16, s, &sum[3]); + sad16_neon(ref_loop[2] + 3 * 16, s, &sum[5]); + sad16_neon(ref_loop[3] + 3 * 16, s, &sum[7]); + + src_ptr += src_stride; + ref_loop[0] += ref_stride; + ref_loop[1] += ref_stride; + ref_loop[2] += ref_stride; + ref_loop[3] += ref_stride; + } + + r0 = vpaddq_u32(sum[0], sum[1]); + r1 = vpaddq_u32(sum[2], sum[3]); + r2 = vpaddq_u32(sum[4], sum[5]); + r3 = vpaddq_u32(sum[6], sum[7]); + r0 = vpaddq_u32(r0, r1); + r1 = vpaddq_u32(r2, r3); + vst1q_u32(res, vpaddq_u32(r0, r1)); +} + +#else + void vpx_sad64x32x4d_neon(const uint8_t *src_ptr, int src_stride, const uint8_t *const ref_array[4], int ref_stride, uint32_t *res) { @@ -378,3 +648,5 @@ void vpx_sad64x64x4d_neon(const uint8_t *src_ptr, int src_stride, sad_4096_pel_final_neon(sum, res); } + +#endif diff --git a/third_party/libvpx/vpx_dsp/arm/sad_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c similarity index 95% rename from third_party/libvpx/vpx_dsp/arm/sad_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c index c4a49e366d53..59567bda5bae 100644 --- a/third_party/libvpx/vpx_dsp/arm/sad_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c @@ -23,7 +23,7 @@ uint32_t vpx_sad4x4_neon(const uint8_t *src_ptr, int src_stride, const uint8x16_t ref_u8 = load_unaligned_u8q(ref_ptr, ref_stride); uint16x8_t abs = vabdl_u8(vget_low_u8(src_u8), vget_low_u8(ref_u8)); abs = vabal_u8(abs, vget_high_u8(src_u8), vget_high_u8(ref_u8)); - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); + return horizontal_add_uint16x8(abs); } uint32_t vpx_sad4x4_avg_neon(const uint8_t *src_ptr, int src_stride, @@ -35,7 +35,7 @@ uint32_t vpx_sad4x4_avg_neon(const uint8_t *src_ptr, int src_stride, const uint8x16_t avg = vrhaddq_u8(ref_u8, second_pred_u8); uint16x8_t abs = vabdl_u8(vget_low_u8(src_u8), vget_low_u8(avg)); abs = vabal_u8(abs, vget_high_u8(src_u8), vget_high_u8(avg)); - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); + return horizontal_add_uint16x8(abs); } uint32_t vpx_sad4x8_neon(const uint8_t *src_ptr, int src_stride, @@ -51,7 +51,7 @@ uint32_t vpx_sad4x8_neon(const uint8_t *src_ptr, int src_stride, abs = vabal_u8(abs, vget_high_u8(src_u8), vget_high_u8(ref_u8)); } - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); + return horizontal_add_uint16x8(abs); } uint32_t vpx_sad4x8_avg_neon(const uint8_t *src_ptr, int src_stride, @@ -71,7 +71,7 @@ uint32_t vpx_sad4x8_avg_neon(const uint8_t *src_ptr, int src_stride, abs = vabal_u8(abs, vget_high_u8(src_u8), vget_high_u8(avg)); } - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); + return horizontal_add_uint16x8(abs); } static INLINE uint16x8_t sad8x(const uint8_t *src_ptr, int src_stride, @@ -114,7 +114,7 @@ static INLINE uint16x8_t sad8x_avg(const uint8_t *src_ptr, int src_stride, uint32_t vpx_sad8x##n##_neon(const uint8_t *src_ptr, int src_stride, \ const uint8_t *ref_ptr, int ref_stride) { \ const uint16x8_t abs = sad8x(src_ptr, src_stride, ref_ptr, ref_stride, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } \ \ uint32_t vpx_sad8x##n##_avg_neon(const uint8_t *src_ptr, int src_stride, \ @@ -122,7 +122,7 @@ static INLINE uint16x8_t sad8x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *second_pred) { \ const uint16x8_t abs = \ sad8x_avg(src_ptr, src_stride, ref_ptr, ref_stride, second_pred, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } sad8xN(4); @@ -172,7 +172,7 @@ static INLINE uint16x8_t sad16x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride) { \ const uint16x8_t abs = \ sad16x(src_ptr, src_stride, ref_ptr, ref_stride, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } \ \ uint32_t vpx_sad16x##n##_avg_neon(const uint8_t *src_ptr, int src_stride, \ @@ -180,7 +180,7 @@ static INLINE uint16x8_t sad16x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *second_pred) { \ const uint16x8_t abs = \ sad16x_avg(src_ptr, src_stride, ref_ptr, ref_stride, second_pred, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } sad16xN(8); @@ -240,7 +240,7 @@ static INLINE uint16x8_t sad32x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride) { \ const uint16x8_t abs = \ sad32x(src_ptr, src_stride, ref_ptr, ref_stride, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } \ \ uint32_t vpx_sad32x##n##_avg_neon(const uint8_t *src_ptr, int src_stride, \ @@ -248,7 +248,7 @@ static INLINE uint16x8_t sad32x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *second_pred) { \ const uint16x8_t abs = \ sad32x_avg(src_ptr, src_stride, ref_ptr, ref_stride, second_pred, n); \ - return vget_lane_u32(horizontal_add_uint16x8(abs), 0); \ + return horizontal_add_uint16x8(abs); \ } sad32xN(16); @@ -338,7 +338,7 @@ static INLINE uint32x4_t sad64x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride) { \ const uint32x4_t abs = \ sad64x(src_ptr, src_stride, ref_ptr, ref_stride, n); \ - return vget_lane_u32(horizontal_add_uint32x4(abs), 0); \ + return horizontal_add_uint32x4(abs); \ } \ \ uint32_t vpx_sad64x##n##_avg_neon(const uint8_t *src_ptr, int src_stride, \ @@ -346,7 +346,7 @@ static INLINE uint32x4_t sad64x_avg(const uint8_t *src_ptr, int src_stride, const uint8_t *second_pred) { \ const uint32x4_t abs = \ sad64x_avg(src_ptr, src_stride, ref_ptr, ref_stride, second_pred, n); \ - return vget_lane_u32(horizontal_add_uint32x4(abs), 0); \ + return horizontal_add_uint32x4(abs); \ } sad64xN(32); diff --git a/third_party/libvpx/vpx_dsp/arm/save_reg_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/save_reg_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/save_reg_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/save_reg_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/subpel_variance_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/subpel_variance_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/subtract_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/subtract_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c diff --git a/third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h new file mode 100644 index 000000000000..9a7c424e8e4a --- /dev/null +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_VPX_DSP_ARM_SUM_NEON_H_ +#define VPX_VPX_DSP_ARM_SUM_NEON_H_ + +#include + +#include "./vpx_config.h" +#include "vpx/vpx_integer.h" + +static INLINE int32_t horizontal_add_int16x8(const int16x8_t a) { +#if defined(__aarch64__) + return vaddlvq_s16(a); +#else + const int32x4_t b = vpaddlq_s16(a); + const int64x2_t c = vpaddlq_s32(b); + const int32x2_t d = vadd_s32(vreinterpret_s32_s64(vget_low_s64(c)), + vreinterpret_s32_s64(vget_high_s64(c))); + return vget_lane_s32(d, 0); +#endif +} + +static INLINE uint32_t horizontal_add_uint16x8(const uint16x8_t a) { +#if defined(__aarch64__) + return vaddlvq_u16(a); +#else + const uint32x4_t b = vpaddlq_u16(a); + const uint64x2_t c = vpaddlq_u32(b); + const uint32x2_t d = vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)), + vreinterpret_u32_u64(vget_high_u64(c))); + return vget_lane_u32(d, 0); +#endif +} + +static INLINE int32_t horizontal_add_int32x2(const int32x2_t a) { +#if defined(__aarch64__) + return vaddv_s32(a); +#else + return vget_lane_s32(a, 0) + vget_lane_s32(a, 1); +#endif +} + +static INLINE uint32_t horizontal_add_uint32x2(const uint32x2_t a) { +#if defined(__aarch64__) + return vaddv_u32(a); +#else + return vget_lane_u32(a, 0) + vget_lane_u32(a, 1); +#endif +} + +static INLINE int32_t horizontal_add_int32x4(const int32x4_t a) { +#if defined(__aarch64__) + return vaddvq_s32(a); +#else + const int64x2_t b = vpaddlq_s32(a); + const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)), + vreinterpret_s32_s64(vget_high_s64(b))); + return vget_lane_s32(c, 0); +#endif +} + +static INLINE uint32_t horizontal_add_uint32x4(const uint32x4_t a) { +#if defined(__aarch64__) + return vaddvq_u32(a); +#else + const uint64x2_t b = vpaddlq_u32(a); + const uint32x2_t c = vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)), + vreinterpret_u32_u64(vget_high_u64(b))); + return vget_lane_u32(c, 0); +#endif +} +#endif // VPX_VPX_DSP_ARM_SUM_NEON_H_ diff --git a/third_party/libvpx/vpx_dsp/arm/sum_squares_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/sum_squares_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/transpose_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/transpose_neon.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h diff --git a/third_party/libvpx/vpx_dsp/arm/variance_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c similarity index 56% rename from third_party/libvpx/vpx_dsp/arm/variance_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c index 77b1015b742a..410ce7d9e69e 100644 --- a/third_party/libvpx/vpx_dsp/arm/variance_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c @@ -19,6 +19,100 @@ #include "vpx_dsp/arm/sum_neon.h" #include "vpx_ports/mem.h" +#if defined(__ARM_FEATURE_DOTPROD) && (__ARM_FEATURE_DOTPROD == 1) + +// Process a block of width 4 four rows at a time. +static void variance_neon_w4x4(const uint8_t *src_ptr, int src_stride, + const uint8_t *ref_ptr, int ref_stride, int h, + uint32_t *sse, int *sum) { + int i; + uint32x4_t sum_a = vdupq_n_u32(0); + uint32x4_t sum_b = vdupq_n_u32(0); + uint32x4_t sse_u32 = vdupq_n_u32(0); + + for (i = 0; i < h; i += 4) { + const uint8x16_t a = load_unaligned_u8q(src_ptr, src_stride); + const uint8x16_t b = load_unaligned_u8q(ref_ptr, ref_stride); + + const uint8x16_t abs_diff = vabdq_u8(a, b); + sse_u32 = vdotq_u32(sse_u32, abs_diff, abs_diff); + + sum_a = vdotq_u32(sum_a, a, vdupq_n_u8(1)); + sum_b = vdotq_u32(sum_b, b, vdupq_n_u8(1)); + + src_ptr += 4 * src_stride; + ref_ptr += 4 * ref_stride; + } + + *sum = horizontal_add_int32x4(vreinterpretq_s32_u32(vsubq_u32(sum_a, sum_b))); + *sse = horizontal_add_uint32x4(sse_u32); +} + +// Process a block of any size where the width is divisible by 16. +static void variance_neon_w16(const uint8_t *src_ptr, int src_stride, + const uint8_t *ref_ptr, int ref_stride, int w, + int h, uint32_t *sse, int *sum) { + int i, j; + uint32x4_t sum_a = vdupq_n_u32(0); + uint32x4_t sum_b = vdupq_n_u32(0); + uint32x4_t sse_u32 = vdupq_n_u32(0); + + for (i = 0; i < h; ++i) { + for (j = 0; j < w; j += 16) { + const uint8x16_t a = vld1q_u8(src_ptr + j); + const uint8x16_t b = vld1q_u8(ref_ptr + j); + + const uint8x16_t abs_diff = vabdq_u8(a, b); + sse_u32 = vdotq_u32(sse_u32, abs_diff, abs_diff); + + sum_a = vdotq_u32(sum_a, a, vdupq_n_u8(1)); + sum_b = vdotq_u32(sum_b, b, vdupq_n_u8(1)); + } + src_ptr += src_stride; + ref_ptr += ref_stride; + } + + *sum = horizontal_add_int32x4(vreinterpretq_s32_u32(vsubq_u32(sum_a, sum_b))); + *sse = horizontal_add_uint32x4(sse_u32); +} + +// Process a block of width 8 two rows at a time. +static void variance_neon_w8x2(const uint8_t *src_ptr, int src_stride, + const uint8_t *ref_ptr, int ref_stride, int h, + uint32_t *sse, int *sum) { + int i = 0; + uint32x2_t sum_a = vdup_n_u32(0); + uint32x2_t sum_b = vdup_n_u32(0); + uint32x2_t sse_lo_u32 = vdup_n_u32(0); + uint32x2_t sse_hi_u32 = vdup_n_u32(0); + + do { + const uint8x8_t a_0 = vld1_u8(src_ptr); + const uint8x8_t a_1 = vld1_u8(src_ptr + src_stride); + const uint8x8_t b_0 = vld1_u8(ref_ptr); + const uint8x8_t b_1 = vld1_u8(ref_ptr + ref_stride); + + const uint8x8_t abs_diff_0 = vabd_u8(a_0, b_0); + const uint8x8_t abs_diff_1 = vabd_u8(a_1, b_1); + sse_lo_u32 = vdot_u32(sse_lo_u32, abs_diff_0, abs_diff_0); + sse_hi_u32 = vdot_u32(sse_hi_u32, abs_diff_1, abs_diff_1); + + sum_a = vdot_u32(sum_a, a_0, vdup_n_u8(1)); + sum_b = vdot_u32(sum_b, b_0, vdup_n_u8(1)); + sum_a = vdot_u32(sum_a, a_1, vdup_n_u8(1)); + sum_b = vdot_u32(sum_b, b_1, vdup_n_u8(1)); + + src_ptr += src_stride + src_stride; + ref_ptr += ref_stride + ref_stride; + i += 2; + } while (i < h); + + *sum = horizontal_add_int32x2(vreinterpret_s32_u32(vsub_u32(sum_a, sum_b))); + *sse = horizontal_add_uint32x2(vadd_u32(sse_lo_u32, sse_hi_u32)); +} + +#else + // The variance helper functions use int16_t for sum. 8 values are accumulated // and then added (at which point they expand up to int32_t). To avoid overflow, // there can be no more than 32767 / 255 ~= 128 values accumulated in each @@ -66,10 +160,9 @@ static void variance_neon_w4x4(const uint8_t *src_ptr, int src_stride, ref_ptr += 4 * ref_stride; } - *sum = vget_lane_s32(horizontal_add_int16x8(sum_s16), 0); - *sse = vget_lane_u32(horizontal_add_uint32x4(vreinterpretq_u32_s32( - vaddq_s32(sse_lo_s32, sse_hi_s32))), - 0); + *sum = horizontal_add_int16x8(sum_s16); + *sse = horizontal_add_uint32x4( + vreinterpretq_u32_s32(vaddq_s32(sse_lo_s32, sse_hi_s32))); } // Process a block of any size where the width is divisible by 16. @@ -115,10 +208,9 @@ static void variance_neon_w16(const uint8_t *src_ptr, int src_stride, ref_ptr += ref_stride; } - *sum = vget_lane_s32(horizontal_add_int16x8(sum_s16), 0); - *sse = vget_lane_u32(horizontal_add_uint32x4(vreinterpretq_u32_s32( - vaddq_s32(sse_lo_s32, sse_hi_s32))), - 0); + *sum = horizontal_add_int16x8(sum_s16); + *sse = horizontal_add_uint32x4( + vreinterpretq_u32_s32(vaddq_s32(sse_lo_s32, sse_hi_s32))); } // Process a block of width 8 two rows at a time. @@ -157,12 +249,13 @@ static void variance_neon_w8x2(const uint8_t *src_ptr, int src_stride, i += 2; } while (i < h); - *sum = vget_lane_s32(horizontal_add_int16x8(sum_s16), 0); - *sse = vget_lane_u32(horizontal_add_uint32x4(vreinterpretq_u32_s32( - vaddq_s32(sse_lo_s32, sse_hi_s32))), - 0); + *sum = horizontal_add_int16x8(sum_s16); + *sse = horizontal_add_uint32x4( + vreinterpretq_u32_s32(vaddq_s32(sse_lo_s32, sse_hi_s32))); } +#endif + void vpx_get8x8var_neon(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum) { @@ -264,117 +357,165 @@ unsigned int vpx_variance64x64_neon(const uint8_t *src_ptr, int src_stride, return *sse - (unsigned int)(((int64_t)sum1 * sum1) >> 12); } +#if defined(__ARM_FEATURE_DOTPROD) && (__ARM_FEATURE_DOTPROD == 1) + unsigned int vpx_mse16x16_neon(const unsigned char *src_ptr, int src_stride, const unsigned char *ref_ptr, int ref_stride, unsigned int *sse) { int i; - int16x4_t d22s16, d23s16, d24s16, d25s16, d26s16, d27s16, d28s16, d29s16; - int64x1_t d0s64; - uint8x16_t q0u8, q1u8, q2u8, q3u8; - int32x4_t q7s32, q8s32, q9s32, q10s32; - uint16x8_t q11u16, q12u16, q13u16, q14u16; - int64x2_t q1s64; - - q7s32 = vdupq_n_s32(0); - q8s32 = vdupq_n_s32(0); - q9s32 = vdupq_n_s32(0); - q10s32 = vdupq_n_s32(0); - - for (i = 0; i < 8; i++) { // mse16x16_neon_loop - q0u8 = vld1q_u8(src_ptr); + uint8x16_t a[2], b[2], abs_diff[2]; + uint32x4_t sse_vec[2] = { vdupq_n_u32(0), vdupq_n_u32(0) }; + + for (i = 0; i < 8; i++) { + a[0] = vld1q_u8(src_ptr); src_ptr += src_stride; - q1u8 = vld1q_u8(src_ptr); + a[1] = vld1q_u8(src_ptr); src_ptr += src_stride; - q2u8 = vld1q_u8(ref_ptr); + b[0] = vld1q_u8(ref_ptr); ref_ptr += ref_stride; - q3u8 = vld1q_u8(ref_ptr); + b[1] = vld1q_u8(ref_ptr); ref_ptr += ref_stride; - q11u16 = vsubl_u8(vget_low_u8(q0u8), vget_low_u8(q2u8)); - q12u16 = vsubl_u8(vget_high_u8(q0u8), vget_high_u8(q2u8)); - q13u16 = vsubl_u8(vget_low_u8(q1u8), vget_low_u8(q3u8)); - q14u16 = vsubl_u8(vget_high_u8(q1u8), vget_high_u8(q3u8)); - - d22s16 = vreinterpret_s16_u16(vget_low_u16(q11u16)); - d23s16 = vreinterpret_s16_u16(vget_high_u16(q11u16)); - q7s32 = vmlal_s16(q7s32, d22s16, d22s16); - q8s32 = vmlal_s16(q8s32, d23s16, d23s16); - - d24s16 = vreinterpret_s16_u16(vget_low_u16(q12u16)); - d25s16 = vreinterpret_s16_u16(vget_high_u16(q12u16)); - q9s32 = vmlal_s16(q9s32, d24s16, d24s16); - q10s32 = vmlal_s16(q10s32, d25s16, d25s16); - - d26s16 = vreinterpret_s16_u16(vget_low_u16(q13u16)); - d27s16 = vreinterpret_s16_u16(vget_high_u16(q13u16)); - q7s32 = vmlal_s16(q7s32, d26s16, d26s16); - q8s32 = vmlal_s16(q8s32, d27s16, d27s16); - - d28s16 = vreinterpret_s16_u16(vget_low_u16(q14u16)); - d29s16 = vreinterpret_s16_u16(vget_high_u16(q14u16)); - q9s32 = vmlal_s16(q9s32, d28s16, d28s16); - q10s32 = vmlal_s16(q10s32, d29s16, d29s16); - } - - q7s32 = vaddq_s32(q7s32, q8s32); - q9s32 = vaddq_s32(q9s32, q10s32); - q10s32 = vaddq_s32(q7s32, q9s32); + abs_diff[0] = vabdq_u8(a[0], b[0]); + abs_diff[1] = vabdq_u8(a[1], b[1]); - q1s64 = vpaddlq_s32(q10s32); - d0s64 = vadd_s64(vget_low_s64(q1s64), vget_high_s64(q1s64)); + sse_vec[0] = vdotq_u32(sse_vec[0], abs_diff[0], abs_diff[0]); + sse_vec[1] = vdotq_u32(sse_vec[1], abs_diff[1], abs_diff[1]); + } - vst1_lane_u32((uint32_t *)sse, vreinterpret_u32_s64(d0s64), 0); - return vget_lane_u32(vreinterpret_u32_s64(d0s64), 0); + *sse = horizontal_add_uint32x4(vaddq_u32(sse_vec[0], sse_vec[1])); + return horizontal_add_uint32x4(vaddq_u32(sse_vec[0], sse_vec[1])); } unsigned int vpx_get4x4sse_cs_neon(const unsigned char *src_ptr, int src_stride, const unsigned char *ref_ptr, int ref_stride) { - int16x4_t d22s16, d24s16, d26s16, d28s16; - int64x1_t d0s64; - uint8x8_t d0u8, d1u8, d2u8, d3u8, d4u8, d5u8, d6u8, d7u8; - int32x4_t q7s32, q8s32, q9s32, q10s32; - uint16x8_t q11u16, q12u16, q13u16, q14u16; - int64x2_t q1s64; - - d0u8 = vld1_u8(src_ptr); - src_ptr += src_stride; - d4u8 = vld1_u8(ref_ptr); - ref_ptr += ref_stride; - d1u8 = vld1_u8(src_ptr); + uint8x8_t a[4], b[4], abs_diff[4]; + uint32x2_t sse = vdup_n_u32(0); + + a[0] = vld1_u8(src_ptr); src_ptr += src_stride; - d5u8 = vld1_u8(ref_ptr); + b[0] = vld1_u8(ref_ptr); ref_ptr += ref_stride; - d2u8 = vld1_u8(src_ptr); + a[1] = vld1_u8(src_ptr); src_ptr += src_stride; - d6u8 = vld1_u8(ref_ptr); + b[1] = vld1_u8(ref_ptr); ref_ptr += ref_stride; - d3u8 = vld1_u8(src_ptr); + a[2] = vld1_u8(src_ptr); src_ptr += src_stride; - d7u8 = vld1_u8(ref_ptr); + b[2] = vld1_u8(ref_ptr); ref_ptr += ref_stride; + a[3] = vld1_u8(src_ptr); + b[3] = vld1_u8(ref_ptr); - q11u16 = vsubl_u8(d0u8, d4u8); - q12u16 = vsubl_u8(d1u8, d5u8); - q13u16 = vsubl_u8(d2u8, d6u8); - q14u16 = vsubl_u8(d3u8, d7u8); + abs_diff[0] = vabd_u8(a[0], b[0]); + abs_diff[1] = vabd_u8(a[1], b[1]); + abs_diff[2] = vabd_u8(a[2], b[2]); + abs_diff[3] = vabd_u8(a[3], b[3]); - d22s16 = vget_low_s16(vreinterpretq_s16_u16(q11u16)); - d24s16 = vget_low_s16(vreinterpretq_s16_u16(q12u16)); - d26s16 = vget_low_s16(vreinterpretq_s16_u16(q13u16)); - d28s16 = vget_low_s16(vreinterpretq_s16_u16(q14u16)); + sse = vdot_u32(sse, abs_diff[0], abs_diff[0]); + sse = vdot_u32(sse, abs_diff[1], abs_diff[1]); + sse = vdot_u32(sse, abs_diff[2], abs_diff[2]); + sse = vdot_u32(sse, abs_diff[3], abs_diff[3]); - q7s32 = vmull_s16(d22s16, d22s16); - q8s32 = vmull_s16(d24s16, d24s16); - q9s32 = vmull_s16(d26s16, d26s16); - q10s32 = vmull_s16(d28s16, d28s16); + return vget_lane_u32(sse, 0); +} - q7s32 = vaddq_s32(q7s32, q8s32); - q9s32 = vaddq_s32(q9s32, q10s32); - q9s32 = vaddq_s32(q7s32, q9s32); +#else - q1s64 = vpaddlq_s32(q9s32); - d0s64 = vadd_s64(vget_low_s64(q1s64), vget_high_s64(q1s64)); +unsigned int vpx_mse16x16_neon(const unsigned char *src_ptr, int src_stride, + const unsigned char *ref_ptr, int ref_stride, + unsigned int *sse) { + int i; + uint8x16_t a[2], b[2]; + int16x4_t diff_lo[4], diff_hi[4]; + uint16x8_t diff[4]; + int32x4_t sse_vec[4] = { vdupq_n_s32(0), vdupq_n_s32(0), vdupq_n_s32(0), + vdupq_n_s32(0) }; + + for (i = 0; i < 8; i++) { + a[0] = vld1q_u8(src_ptr); + src_ptr += src_stride; + a[1] = vld1q_u8(src_ptr); + src_ptr += src_stride; + b[0] = vld1q_u8(ref_ptr); + ref_ptr += ref_stride; + b[1] = vld1q_u8(ref_ptr); + ref_ptr += ref_stride; + + diff[0] = vsubl_u8(vget_low_u8(a[0]), vget_low_u8(b[0])); + diff[1] = vsubl_u8(vget_high_u8(a[0]), vget_high_u8(b[0])); + diff[2] = vsubl_u8(vget_low_u8(a[1]), vget_low_u8(b[1])); + diff[3] = vsubl_u8(vget_high_u8(a[1]), vget_high_u8(b[1])); + + diff_lo[0] = vreinterpret_s16_u16(vget_low_u16(diff[0])); + diff_lo[1] = vreinterpret_s16_u16(vget_low_u16(diff[1])); + sse_vec[0] = vmlal_s16(sse_vec[0], diff_lo[0], diff_lo[0]); + sse_vec[1] = vmlal_s16(sse_vec[1], diff_lo[1], diff_lo[1]); + + diff_lo[2] = vreinterpret_s16_u16(vget_low_u16(diff[2])); + diff_lo[3] = vreinterpret_s16_u16(vget_low_u16(diff[3])); + sse_vec[2] = vmlal_s16(sse_vec[2], diff_lo[2], diff_lo[2]); + sse_vec[3] = vmlal_s16(sse_vec[3], diff_lo[3], diff_lo[3]); + + diff_hi[0] = vreinterpret_s16_u16(vget_high_u16(diff[0])); + diff_hi[1] = vreinterpret_s16_u16(vget_high_u16(diff[1])); + sse_vec[0] = vmlal_s16(sse_vec[0], diff_hi[0], diff_hi[0]); + sse_vec[1] = vmlal_s16(sse_vec[1], diff_hi[1], diff_hi[1]); + + diff_hi[2] = vreinterpret_s16_u16(vget_high_u16(diff[2])); + diff_hi[3] = vreinterpret_s16_u16(vget_high_u16(diff[3])); + sse_vec[2] = vmlal_s16(sse_vec[2], diff_hi[2], diff_hi[2]); + sse_vec[3] = vmlal_s16(sse_vec[3], diff_hi[3], diff_hi[3]); + } + + sse_vec[0] = vaddq_s32(sse_vec[0], sse_vec[1]); + sse_vec[2] = vaddq_s32(sse_vec[2], sse_vec[3]); + sse_vec[0] = vaddq_s32(sse_vec[0], sse_vec[2]); + + *sse = horizontal_add_uint32x4(vreinterpretq_u32_s32(sse_vec[0])); + return horizontal_add_uint32x4(vreinterpretq_u32_s32(sse_vec[0])); +} + +unsigned int vpx_get4x4sse_cs_neon(const unsigned char *src_ptr, int src_stride, + const unsigned char *ref_ptr, + int ref_stride) { + uint8x8_t a[4], b[4]; + int16x4_t diff_lo[4]; + uint16x8_t diff[4]; + int32x4_t sse; - return vget_lane_u32(vreinterpret_u32_s64(d0s64), 0); + a[0] = vld1_u8(src_ptr); + src_ptr += src_stride; + b[0] = vld1_u8(ref_ptr); + ref_ptr += ref_stride; + a[1] = vld1_u8(src_ptr); + src_ptr += src_stride; + b[1] = vld1_u8(ref_ptr); + ref_ptr += ref_stride; + a[2] = vld1_u8(src_ptr); + src_ptr += src_stride; + b[2] = vld1_u8(ref_ptr); + ref_ptr += ref_stride; + a[3] = vld1_u8(src_ptr); + b[3] = vld1_u8(ref_ptr); + + diff[0] = vsubl_u8(a[0], b[0]); + diff[1] = vsubl_u8(a[1], b[1]); + diff[2] = vsubl_u8(a[2], b[2]); + diff[3] = vsubl_u8(a[3], b[3]); + + diff_lo[0] = vget_low_s16(vreinterpretq_s16_u16(diff[0])); + diff_lo[1] = vget_low_s16(vreinterpretq_s16_u16(diff[1])); + diff_lo[2] = vget_low_s16(vreinterpretq_s16_u16(diff[2])); + diff_lo[3] = vget_low_s16(vreinterpretq_s16_u16(diff[3])); + + sse = vmull_s16(diff_lo[0], diff_lo[0]); + sse = vmlal_s16(sse, diff_lo[1], diff_lo[1]); + sse = vmlal_s16(sse, diff_lo[2], diff_lo[2]); + sse = vmlal_s16(sse, diff_lo[3], diff_lo[3]); + + return horizontal_add_uint32x4(vreinterpretq_u32_s32(sse)); } + +#endif diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type1_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type1_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type1_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type1_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type2_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type2_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type2_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_horiz_filter_type2_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type1_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type1_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type1_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type1_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type2_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type2_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type2_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_avg_vert_filter_type2_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type1_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type1_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type1_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type1_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type2_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type2_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type2_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_horiz_filter_type2_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c similarity index 56% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c index 08ae17dbabff..06b58c438f1c 100644 --- a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c @@ -14,6 +14,7 @@ #include "./vpx_config.h" #include "./vpx_dsp_rtcd.h" #include "vpx/vpx_integer.h" +#include "vpx_dsp/arm/mem_neon.h" #include "vpx_dsp/arm/transpose_neon.h" #include "vpx_dsp/arm/vpx_convolve8_neon.h" #include "vpx_ports/mem.h" @@ -30,6 +31,741 @@ // instructions. This optimization is much faster in speed unit test, but slowed // down the whole decoder by 5%. +#if defined(__aarch64__) && defined(__ARM_FEATURE_DOTPROD) && \ + (__ARM_FEATURE_DOTPROD == 1) +DECLARE_ALIGNED(16, static const uint8_t, dot_prod_permute_tbl[48]) = { + 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, + 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10, + 8, 9, 10, 11, 9, 10, 11, 12, 10, 11, 12, 13, 11, 12, 13, 14 +}; + +DECLARE_ALIGNED(16, static const uint8_t, dot_prod_tran_concat_tbl[32]) = { + 0, 8, 16, 24, 1, 9, 17, 25, 2, 10, 18, 26, 3, 11, 19, 27, + 4, 12, 20, 28, 5, 13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31 +}; + +DECLARE_ALIGNED(16, static const uint8_t, dot_prod_merge_block_tbl[48]) = { + /* Shift left and insert new last column in transposed 4x4 block. */ + 1, 2, 3, 16, 5, 6, 7, 20, 9, 10, 11, 24, 13, 14, 15, 28, + /* Shift left and insert two new columns in transposed 4x4 block. */ + 2, 3, 16, 17, 6, 7, 20, 21, 10, 11, 24, 25, 14, 15, 28, 29, + /* Shift left and insert three new columns in transposed 4x4 block. */ + 3, 16, 17, 18, 7, 20, 21, 22, 11, 24, 25, 26, 15, 28, 29, 30 +}; + +static INLINE void transpose_concat_4x4(int8x8_t *a0, int8x8_t *a1, + int8x8_t *a2, int8x8_t *a3, + int8x16_t *b, + const uint8x16_t permute_tbl) { + /* Transpose 8-bit elements and concatenate result rows as follows: + * a0: 00, 01, 02, 03, XX, XX, XX, XX + * a1: 10, 11, 12, 13, XX, XX, XX, XX + * a2: 20, 21, 22, 23, XX, XX, XX, XX + * a3: 30, 31, 32, 33, XX, XX, XX, XX + * + * b: 00, 10, 20, 30, 01, 11, 21, 31, 02, 12, 22, 32, 03, 13, 23, 33 + * + * The 'permute_tbl' is always 'dot_prod_tran_concat_tbl' above. Passing it + * as an argument is preferable to loading it directly from memory as this + * inline helper is called many times from the same parent function. + */ + + int8x16x2_t samples = { { vcombine_s8(*a0, *a1), vcombine_s8(*a2, *a3) } }; + *b = vqtbl2q_s8(samples, permute_tbl); +} + +static INLINE void transpose_concat_8x4(int8x8_t *a0, int8x8_t *a1, + int8x8_t *a2, int8x8_t *a3, + int8x16_t *b0, int8x16_t *b1, + const uint8x16x2_t permute_tbl) { + /* Transpose 8-bit elements and concatenate result rows as follows: + * a0: 00, 01, 02, 03, 04, 05, 06, 07 + * a1: 10, 11, 12, 13, 14, 15, 16, 17 + * a2: 20, 21, 22, 23, 24, 25, 26, 27 + * a3: 30, 31, 32, 33, 34, 35, 36, 37 + * + * b0: 00, 10, 20, 30, 01, 11, 21, 31, 02, 12, 22, 32, 03, 13, 23, 33 + * b1: 04, 14, 24, 34, 05, 15, 25, 35, 06, 16, 26, 36, 07, 17, 27, 37 + * + * The 'permute_tbl' is always 'dot_prod_tran_concat_tbl' above. Passing it + * as an argument is preferable to loading it directly from memory as this + * inline helper is called many times from the same parent function. + */ + + int8x16x2_t samples = { { vcombine_s8(*a0, *a1), vcombine_s8(*a2, *a3) } }; + *b0 = vqtbl2q_s8(samples, permute_tbl.val[0]); + *b1 = vqtbl2q_s8(samples, permute_tbl.val[1]); +} + +void vpx_convolve8_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, + uint8_t *dst, ptrdiff_t dst_stride, + const InterpKernel *filter, int x0_q4, + int x_step_q4, int y0_q4, int y_step_q4, int w, + int h) { + const int8x8_t filters = vmovn_s16(vld1q_s16(filter[x0_q4])); + const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter[x0_q4]), 128); + const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp)); + const uint8x16_t range_limit = vdupq_n_u8(128); + uint8x16_t s0, s1, s2, s3; + + assert(!((intptr_t)dst & 3)); + assert(!(dst_stride & 3)); + assert(x_step_q4 == 16); + + (void)x_step_q4; + (void)y0_q4; + (void)y_step_q4; + + src -= 3; + + if (w == 4) { + const uint8x16x2_t permute_tbl = vld1q_u8_x2(dot_prod_permute_tbl); + do { + int32x4_t t0, t1, t2, t3; + int16x8_t t01, t23; + uint8x8_t d01, d23; + + s0 = vld1q_u8(src); + src += src_stride; + s1 = vld1q_u8(src); + src += src_stride; + s2 = vld1q_u8(src); + src += src_stride; + s3 = vld1q_u8(src); + src += src_stride; + + t0 = convolve8_4_dot(s0, filters, correction, range_limit, permute_tbl); + t1 = convolve8_4_dot(s1, filters, correction, range_limit, permute_tbl); + t2 = convolve8_4_dot(s2, filters, correction, range_limit, permute_tbl); + t3 = convolve8_4_dot(s3, filters, correction, range_limit, permute_tbl); + + t01 = vcombine_s16(vqmovn_s32(t0), vqmovn_s32(t1)); + t23 = vcombine_s16(vqmovn_s32(t2), vqmovn_s32(t3)); + d01 = vqrshrun_n_s16(t01, 7); + d23 = vqrshrun_n_s16(t23, 7); + + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 1); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 1); + dst += dst_stride; + h -= 4; + } while (h > 0); + } else { + const uint8x16x3_t permute_tbl = vld1q_u8_x3(dot_prod_permute_tbl); + const uint8_t *s; + uint8_t *d; + int width; + uint8x8_t d0, d1, d2, d3; + + do { + width = w; + s = src; + d = dst; + do { + s0 = vld1q_u8(s + 0 * src_stride); + s1 = vld1q_u8(s + 1 * src_stride); + s2 = vld1q_u8(s + 2 * src_stride); + s3 = vld1q_u8(s + 3 * src_stride); + + d0 = convolve8_8_dot(s0, filters, correction, range_limit, permute_tbl); + d1 = convolve8_8_dot(s1, filters, correction, range_limit, permute_tbl); + d2 = convolve8_8_dot(s2, filters, correction, range_limit, permute_tbl); + d3 = convolve8_8_dot(s3, filters, correction, range_limit, permute_tbl); + + vst1_u8(d + 0 * dst_stride, d0); + vst1_u8(d + 1 * dst_stride, d1); + vst1_u8(d + 2 * dst_stride, d2); + vst1_u8(d + 3 * dst_stride, d3); + + s += 8; + d += 8; + width -= 8; + } while (width > 0); + src += 4 * src_stride; + dst += 4 * dst_stride; + h -= 4; + } while (h > 0); + } +} + +void vpx_convolve8_avg_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, + uint8_t *dst, ptrdiff_t dst_stride, + const InterpKernel *filter, int x0_q4, + int x_step_q4, int y0_q4, int y_step_q4, + int w, int h) { + const int8x8_t filters = vmovn_s16(vld1q_s16(filter[x0_q4])); + const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter[x0_q4]), 128); + const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp)); + const uint8x16_t range_limit = vdupq_n_u8(128); + uint8x16_t s0, s1, s2, s3; + + assert(!((intptr_t)dst & 3)); + assert(!(dst_stride & 3)); + assert(x_step_q4 == 16); + + (void)x_step_q4; + (void)y0_q4; + (void)y_step_q4; + + src -= 3; + + if (w == 4) { + const uint8x16x2_t permute_tbl = vld1q_u8_x2(dot_prod_permute_tbl); + do { + int32x4_t t0, t1, t2, t3; + int16x8_t t01, t23; + uint8x8_t d01, d23, dd01, dd23; + dd01 = vdup_n_u8(0); + dd23 = vdup_n_u8(0); + + s0 = vld1q_u8(src); + src += src_stride; + s1 = vld1q_u8(src); + src += src_stride; + s2 = vld1q_u8(src); + src += src_stride; + s3 = vld1q_u8(src); + src += src_stride; + + t0 = convolve8_4_dot(s0, filters, correction, range_limit, permute_tbl); + t1 = convolve8_4_dot(s1, filters, correction, range_limit, permute_tbl); + t2 = convolve8_4_dot(s2, filters, correction, range_limit, permute_tbl); + t3 = convolve8_4_dot(s3, filters, correction, range_limit, permute_tbl); + + t01 = vcombine_s16(vqmovn_s32(t0), vqmovn_s32(t1)); + t23 = vcombine_s16(vqmovn_s32(t2), vqmovn_s32(t3)); + d01 = vqrshrun_n_s16(t01, 7); + d23 = vqrshrun_n_s16(t23, 7); + + dd01 = load_u8(dst + 0 * dst_stride, dst_stride); + dd23 = load_u8(dst + 2 * dst_stride, dst_stride); + d01 = vrhadd_u8(d01, dd01); + d23 = vrhadd_u8(d23, dd23); + + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 1); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 1); + dst += dst_stride; + h -= 4; + } while (h > 0); + } else { + const uint8x16x3_t permute_tbl = vld1q_u8_x3(dot_prod_permute_tbl); + const uint8_t *s; + uint8_t *d; + int width; + uint8x8_t d0, d1, d2, d3, dd0, dd1, dd2, dd3; + + do { + width = w; + s = src; + d = dst; + do { + s0 = vld1q_u8(s + 0 * src_stride); + s1 = vld1q_u8(s + 1 * src_stride); + s2 = vld1q_u8(s + 2 * src_stride); + s3 = vld1q_u8(s + 3 * src_stride); + + d0 = convolve8_8_dot(s0, filters, correction, range_limit, permute_tbl); + d1 = convolve8_8_dot(s1, filters, correction, range_limit, permute_tbl); + d2 = convolve8_8_dot(s2, filters, correction, range_limit, permute_tbl); + d3 = convolve8_8_dot(s3, filters, correction, range_limit, permute_tbl); + + dd0 = vld1_u8(d + 0 * dst_stride); + dd1 = vld1_u8(d + 1 * dst_stride); + dd2 = vld1_u8(d + 2 * dst_stride); + dd3 = vld1_u8(d + 3 * dst_stride); + d0 = vrhadd_u8(d0, dd0); + d1 = vrhadd_u8(d1, dd1); + d2 = vrhadd_u8(d2, dd2); + d3 = vrhadd_u8(d3, dd3); + + vst1_u8(d + 0 * dst_stride, d0); + vst1_u8(d + 1 * dst_stride, d1); + vst1_u8(d + 2 * dst_stride, d2); + vst1_u8(d + 3 * dst_stride, d3); + + s += 8; + d += 8; + width -= 8; + } while (width > 0); + src += 4 * src_stride; + dst += 4 * dst_stride; + h -= 4; + } while (h > 0); + } +} + +void vpx_convolve8_vert_neon(const uint8_t *src, ptrdiff_t src_stride, + uint8_t *dst, ptrdiff_t dst_stride, + const InterpKernel *filter, int x0_q4, + int x_step_q4, int y0_q4, int y_step_q4, int w, + int h) { + const int8x8_t filters = vmovn_s16(vld1q_s16(filter[y0_q4])); + const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter[y0_q4]), 128); + const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp)); + const uint8x8_t range_limit = vdup_n_u8(128); + const uint8x16x3_t merge_block_tbl = vld1q_u8_x3(dot_prod_merge_block_tbl); + uint8x8_t t0, t1, t2, t3, t4, t5, t6; + int8x8_t s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; + int8x16x2_t samples_LUT; + + assert(!((intptr_t)dst & 3)); + assert(!(dst_stride & 3)); + assert(y_step_q4 == 16); + + (void)x0_q4; + (void)x_step_q4; + (void)y_step_q4; + + src -= 3 * src_stride; + + if (w == 4) { + const uint8x16_t tran_concat_tbl = vld1q_u8(dot_prod_tran_concat_tbl); + int8x16_t s0123, s1234, s2345, s3456, s4567, s5678, s6789, s78910; + int32x4_t d0, d1, d2, d3; + uint8x8_t d01, d23; + + load_u8_8x4(src, src_stride, &t0, &t1, &t2, &t3); + src += 4 * src_stride; + t4 = vld1_u8(src); + src += src_stride; + t5 = vld1_u8(src); + src += src_stride; + t6 = vld1_u8(src); + src += src_stride; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit)); + s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit)); + s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit)); + s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit)); + s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit)); + s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit)); + s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit)); + s7 = vdup_n_s8(0); + s8 = vdup_n_s8(0); + s9 = vdup_n_s8(0); + + /* This operation combines a conventional transpose and the sample permute + * (see horizontal case) required before computing the dot product. + */ + transpose_concat_4x4(&s0, &s1, &s2, &s3, &s0123, tran_concat_tbl); + transpose_concat_4x4(&s1, &s2, &s3, &s4, &s1234, tran_concat_tbl); + transpose_concat_4x4(&s2, &s3, &s4, &s5, &s2345, tran_concat_tbl); + transpose_concat_4x4(&s3, &s4, &s5, &s6, &s3456, tran_concat_tbl); + transpose_concat_4x4(&s4, &s5, &s6, &s7, &s4567, tran_concat_tbl); + transpose_concat_4x4(&s5, &s6, &s7, &s8, &s5678, tran_concat_tbl); + transpose_concat_4x4(&s6, &s7, &s8, &s9, &s6789, tran_concat_tbl); + + do { + uint8x8_t t7, t8, t9, t10; + + load_u8_8x4(src, src_stride, &t7, &t8, &t9, &t10); + + s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit)); + s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit)); + s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit)); + s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit)); + + transpose_concat_4x4(&s7, &s8, &s9, &s10, &s78910, tran_concat_tbl); + + /* Merge new data into block from previous iteration. */ + samples_LUT.val[0] = s3456; + samples_LUT.val[1] = s78910; + s4567 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + d0 = convolve8_4_dot_partial(s0123, s4567, correction, filters); + d1 = convolve8_4_dot_partial(s1234, s5678, correction, filters); + d2 = convolve8_4_dot_partial(s2345, s6789, correction, filters); + d3 = convolve8_4_dot_partial(s3456, s78910, correction, filters); + + d01 = vqrshrun_n_s16(vcombine_s16(vqmovn_s32(d0), vqmovn_s32(d1)), 7); + d23 = vqrshrun_n_s16(vcombine_s16(vqmovn_s32(d2), vqmovn_s32(d3)), 7); + + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 1); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 1); + dst += dst_stride; + + /* Prepare block for next iteration - re-using as much as possible. */ + /* Shuffle everything up four rows. */ + s0123 = s4567; + s1234 = s5678; + s2345 = s6789; + s3456 = s78910; + + src += 4 * src_stride; + h -= 4; + } while (h > 0); + } else { + const uint8x16x2_t tran_concat_tbl = vld1q_u8_x2(dot_prod_tran_concat_tbl); + int8x16_t s0123_lo, s0123_hi, s1234_lo, s1234_hi, s2345_lo, s2345_hi, + s3456_lo, s3456_hi, s4567_lo, s4567_hi, s5678_lo, s5678_hi, s6789_lo, + s6789_hi, s78910_lo, s78910_hi; + uint8x8_t d0, d1, d2, d3; + const uint8_t *s; + uint8_t *d; + int height; + + do { + height = h; + s = src; + d = dst; + + load_u8_8x4(s, src_stride, &t0, &t1, &t2, &t3); + s += 4 * src_stride; + t4 = vld1_u8(s); + s += src_stride; + t5 = vld1_u8(s); + s += src_stride; + t6 = vld1_u8(s); + s += src_stride; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit)); + s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit)); + s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit)); + s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit)); + s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit)); + s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit)); + s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit)); + s7 = vdup_n_s8(0); + s8 = vdup_n_s8(0); + s9 = vdup_n_s8(0); + + /* This operation combines a conventional transpose and the sample permute + * (see horizontal case) required before computing the dot product. + */ + transpose_concat_8x4(&s0, &s1, &s2, &s3, &s0123_lo, &s0123_hi, + tran_concat_tbl); + transpose_concat_8x4(&s1, &s2, &s3, &s4, &s1234_lo, &s1234_hi, + tran_concat_tbl); + transpose_concat_8x4(&s2, &s3, &s4, &s5, &s2345_lo, &s2345_hi, + tran_concat_tbl); + transpose_concat_8x4(&s3, &s4, &s5, &s6, &s3456_lo, &s3456_hi, + tran_concat_tbl); + transpose_concat_8x4(&s4, &s5, &s6, &s7, &s4567_lo, &s4567_hi, + tran_concat_tbl); + transpose_concat_8x4(&s5, &s6, &s7, &s8, &s5678_lo, &s5678_hi, + tran_concat_tbl); + transpose_concat_8x4(&s6, &s7, &s8, &s9, &s6789_lo, &s6789_hi, + tran_concat_tbl); + + do { + uint8x8_t t7, t8, t9, t10; + + load_u8_8x4(s, src_stride, &t7, &t8, &t9, &t10); + + s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit)); + s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit)); + s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit)); + s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit)); + + transpose_concat_8x4(&s7, &s8, &s9, &s10, &s78910_lo, &s78910_hi, + tran_concat_tbl); + + /* Merge new data into block from previous iteration. */ + samples_LUT.val[0] = s3456_lo; + samples_LUT.val[1] = s78910_lo; + s4567_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + samples_LUT.val[0] = s3456_hi; + samples_LUT.val[1] = s78910_hi; + s4567_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + d0 = convolve8_8_dot_partial(s0123_lo, s4567_lo, s0123_hi, s4567_hi, + correction, filters); + d1 = convolve8_8_dot_partial(s1234_lo, s5678_lo, s1234_hi, s5678_hi, + correction, filters); + d2 = convolve8_8_dot_partial(s2345_lo, s6789_lo, s2345_hi, s6789_hi, + correction, filters); + d3 = convolve8_8_dot_partial(s3456_lo, s78910_lo, s3456_hi, s78910_hi, + correction, filters); + vst1_u8(d + 0 * dst_stride, d0); + vst1_u8(d + 1 * dst_stride, d1); + vst1_u8(d + 2 * dst_stride, d2); + vst1_u8(d + 3 * dst_stride, d3); + + /* Prepare block for next iteration - re-using as much as possible. */ + /* Shuffle everything up four rows. */ + s0123_lo = s4567_lo; + s0123_hi = s4567_hi; + s1234_lo = s5678_lo; + s1234_hi = s5678_hi; + s2345_lo = s6789_lo; + s2345_hi = s6789_hi; + s3456_lo = s78910_lo; + s3456_hi = s78910_hi; + + s += 4 * src_stride; + d += 4 * dst_stride; + height -= 4; + } while (height > 0); + src += 8; + dst += 8; + w -= 8; + } while (w > 0); + } +} + +void vpx_convolve8_avg_vert_neon(const uint8_t *src, ptrdiff_t src_stride, + uint8_t *dst, ptrdiff_t dst_stride, + const InterpKernel *filter, int x0_q4, + int x_step_q4, int y0_q4, int y_step_q4, int w, + int h) { + const int8x8_t filters = vmovn_s16(vld1q_s16(filter[y0_q4])); + const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter[y0_q4]), 128); + const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp)); + const uint8x8_t range_limit = vdup_n_u8(128); + const uint8x16x3_t merge_block_tbl = vld1q_u8_x3(dot_prod_merge_block_tbl); + uint8x8_t t0, t1, t2, t3, t4, t5, t6; + int8x8_t s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; + int8x16x2_t samples_LUT; + + assert(!((intptr_t)dst & 3)); + assert(!(dst_stride & 3)); + assert(y_step_q4 == 16); + + (void)x0_q4; + (void)x_step_q4; + (void)y_step_q4; + + src -= 3 * src_stride; + + if (w == 4) { + const uint8x16_t tran_concat_tbl = vld1q_u8(dot_prod_tran_concat_tbl); + int8x16_t s0123, s1234, s2345, s3456, s4567, s5678, s6789, s78910; + int32x4_t d0, d1, d2, d3; + uint8x8_t d01, d23, dd01, dd23; + + load_u8_8x4(src, src_stride, &t0, &t1, &t2, &t3); + src += 4 * src_stride; + t4 = vld1_u8(src); + src += src_stride; + t5 = vld1_u8(src); + src += src_stride; + t6 = vld1_u8(src); + src += src_stride; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit)); + s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit)); + s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit)); + s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit)); + s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit)); + s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit)); + s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit)); + s7 = vdup_n_s8(0); + s8 = vdup_n_s8(0); + s9 = vdup_n_s8(0); + + /* This operation combines a conventional transpose and the sample permute + * (see horizontal case) required before computing the dot product. + */ + transpose_concat_4x4(&s0, &s1, &s2, &s3, &s0123, tran_concat_tbl); + transpose_concat_4x4(&s1, &s2, &s3, &s4, &s1234, tran_concat_tbl); + transpose_concat_4x4(&s2, &s3, &s4, &s5, &s2345, tran_concat_tbl); + transpose_concat_4x4(&s3, &s4, &s5, &s6, &s3456, tran_concat_tbl); + transpose_concat_4x4(&s4, &s5, &s6, &s7, &s4567, tran_concat_tbl); + transpose_concat_4x4(&s5, &s6, &s7, &s8, &s5678, tran_concat_tbl); + transpose_concat_4x4(&s6, &s7, &s8, &s9, &s6789, tran_concat_tbl); + + do { + uint8x8_t t7, t8, t9, t10; + + load_u8_8x4(src, src_stride, &t7, &t8, &t9, &t10); + + s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit)); + s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit)); + s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit)); + s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit)); + + transpose_concat_4x4(&s7, &s8, &s9, &s10, &s78910, tran_concat_tbl); + + /* Merge new data into block from previous iteration. */ + samples_LUT.val[0] = s3456; + samples_LUT.val[1] = s78910; + s4567 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + d0 = convolve8_4_dot_partial(s0123, s4567, correction, filters); + d1 = convolve8_4_dot_partial(s1234, s5678, correction, filters); + d2 = convolve8_4_dot_partial(s2345, s6789, correction, filters); + d3 = convolve8_4_dot_partial(s3456, s78910, correction, filters); + + d01 = vqrshrun_n_s16(vcombine_s16(vqmovn_s32(d0), vqmovn_s32(d1)), 7); + d23 = vqrshrun_n_s16(vcombine_s16(vqmovn_s32(d2), vqmovn_s32(d3)), 7); + + dd01 = load_u8(dst + 0 * dst_stride, dst_stride); + dd23 = load_u8(dst + 2 * dst_stride, dst_stride); + d01 = vrhadd_u8(d01, dd01); + d23 = vrhadd_u8(d23, dd23); + + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d01), 1); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 0); + dst += dst_stride; + vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d23), 1); + dst += dst_stride; + + /* Prepare block for next iteration - re-using as much as possible. */ + /* Shuffle everything up four rows. */ + s0123 = s4567; + s1234 = s5678; + s2345 = s6789; + s3456 = s78910; + + src += 4 * src_stride; + h -= 4; + } while (h > 0); + } else { + const uint8x16x2_t tran_concat_tbl = vld1q_u8_x2(dot_prod_tran_concat_tbl); + int8x16_t s0123_lo, s0123_hi, s1234_lo, s1234_hi, s2345_lo, s2345_hi, + s3456_lo, s3456_hi, s4567_lo, s4567_hi, s5678_lo, s5678_hi, s6789_lo, + s6789_hi, s78910_lo, s78910_hi; + uint8x8_t d0, d1, d2, d3, dd0, dd1, dd2, dd3; + const uint8_t *s; + uint8_t *d; + int height; + + do { + height = h; + s = src; + d = dst; + + load_u8_8x4(s, src_stride, &t0, &t1, &t2, &t3); + s += 4 * src_stride; + t4 = vld1_u8(s); + s += src_stride; + t5 = vld1_u8(s); + s += src_stride; + t6 = vld1_u8(s); + s += src_stride; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit)); + s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit)); + s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit)); + s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit)); + s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit)); + s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit)); + s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit)); + s7 = vdup_n_s8(0); + s8 = vdup_n_s8(0); + s9 = vdup_n_s8(0); + + /* This operation combines a conventional transpose and the sample permute + * (see horizontal case) required before computing the dot product. + */ + transpose_concat_8x4(&s0, &s1, &s2, &s3, &s0123_lo, &s0123_hi, + tran_concat_tbl); + transpose_concat_8x4(&s1, &s2, &s3, &s4, &s1234_lo, &s1234_hi, + tran_concat_tbl); + transpose_concat_8x4(&s2, &s3, &s4, &s5, &s2345_lo, &s2345_hi, + tran_concat_tbl); + transpose_concat_8x4(&s3, &s4, &s5, &s6, &s3456_lo, &s3456_hi, + tran_concat_tbl); + transpose_concat_8x4(&s4, &s5, &s6, &s7, &s4567_lo, &s4567_hi, + tran_concat_tbl); + transpose_concat_8x4(&s5, &s6, &s7, &s8, &s5678_lo, &s5678_hi, + tran_concat_tbl); + transpose_concat_8x4(&s6, &s7, &s8, &s9, &s6789_lo, &s6789_hi, + tran_concat_tbl); + + do { + uint8x8_t t7, t8, t9, t10; + + load_u8_8x4(s, src_stride, &t7, &t8, &t9, &t10); + + s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit)); + s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit)); + s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit)); + s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit)); + + transpose_concat_8x4(&s7, &s8, &s9, &s10, &s78910_lo, &s78910_hi, + tran_concat_tbl); + + /* Merge new data into block from previous iteration. */ + samples_LUT.val[0] = s3456_lo; + samples_LUT.val[1] = s78910_lo; + s4567_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + samples_LUT.val[0] = s3456_hi; + samples_LUT.val[1] = s78910_hi; + s4567_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]); + s5678_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]); + s6789_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]); + + d0 = convolve8_8_dot_partial(s0123_lo, s4567_lo, s0123_hi, s4567_hi, + correction, filters); + d1 = convolve8_8_dot_partial(s1234_lo, s5678_lo, s1234_hi, s5678_hi, + correction, filters); + d2 = convolve8_8_dot_partial(s2345_lo, s6789_lo, s2345_hi, s6789_hi, + correction, filters); + d3 = convolve8_8_dot_partial(s3456_lo, s78910_lo, s3456_hi, s78910_hi, + correction, filters); + + dd0 = vld1_u8(d + 0 * dst_stride); + dd1 = vld1_u8(d + 1 * dst_stride); + dd2 = vld1_u8(d + 2 * dst_stride); + dd3 = vld1_u8(d + 3 * dst_stride); + d0 = vrhadd_u8(d0, dd0); + d1 = vrhadd_u8(d1, dd1); + d2 = vrhadd_u8(d2, dd2); + d3 = vrhadd_u8(d3, dd3); + + vst1_u8(d + 0 * dst_stride, d0); + vst1_u8(d + 1 * dst_stride, d1); + vst1_u8(d + 2 * dst_stride, d2); + vst1_u8(d + 3 * dst_stride, d3); + + /* Prepare block for next iteration - re-using as much as possible. */ + /* Shuffle everything up four rows. */ + s0123_lo = s4567_lo; + s0123_hi = s4567_hi; + s1234_lo = s5678_lo; + s1234_hi = s5678_hi; + s2345_lo = s6789_lo; + s2345_hi = s6789_hi; + s3456_lo = s78910_lo; + s3456_hi = s78910_hi; + + s += 4 * src_stride; + d += 4 * dst_stride; + height -= 4; + } while (height > 0); + src += 8; + dst += 8; + w -= 8; + } while (w > 0); + } +} + +#else + static INLINE void store_u8_8x8(uint8_t *s, const ptrdiff_t p, const uint8x8_t s0, const uint8x8_t s1, const uint8x8_t s2, const uint8x8_t s3, @@ -145,7 +881,7 @@ void vpx_convolve8_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, src += 4; dst += 4; w -= 4; - } while (w > 0); + } while (w != 0); } else { const int16x8_t filter3 = vdupq_lane_s16(vget_low_s16(filters), 3); const int16x8_t filter4 = vdupq_lane_s16(vget_high_s16(filters), 0); @@ -296,7 +1032,7 @@ void vpx_convolve8_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, s += 8; d += 8; width -= 8; - } while (width > 0); + } while (width != 0); src += 8 * src_stride; dst += 8 * dst_stride; h -= 8; @@ -402,7 +1138,7 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, src += 4; dst += 4; w -= 4; - } while (w > 0); + } while (w != 0); } else { const int16x8_t filter3 = vdupq_lane_s16(vget_low_s16(filters), 3); const int16x8_t filter4 = vdupq_lane_s16(vget_high_s16(filters), 0); @@ -586,7 +1322,7 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, s += 8; d += 8; width -= 8; - } while (width > 0); + } while (width != 0); src += 8 * src_stride; dst += 8 * dst_stride; h -= 8; @@ -679,7 +1415,7 @@ void vpx_convolve8_vert_neon(const uint8_t *src, ptrdiff_t src_stride, s5 = s9; s6 = s10; h -= 4; - } while (h > 0); + } while (h != 0); } else { const int16x8_t filter3 = vdupq_lane_s16(vget_low_s16(filters), 3); const int16x8_t filter4 = vdupq_lane_s16(vget_high_s16(filters), 0); @@ -759,11 +1495,11 @@ void vpx_convolve8_vert_neon(const uint8_t *src, ptrdiff_t src_stride, s5 = s9; s6 = s10; height -= 4; - } while (height > 0); + } while (height != 0); src += 8; dst += 8; w -= 8; - } while (w > 0); + } while (w != 0); } } @@ -860,7 +1596,7 @@ void vpx_convolve8_avg_vert_neon(const uint8_t *src, ptrdiff_t src_stride, s5 = s9; s6 = s10; h -= 4; - } while (h > 0); + } while (h != 0); } else { const int16x8_t filter3 = vdupq_lane_s16(vget_low_s16(filters), 3); const int16x8_t filter4 = vdupq_lane_s16(vget_high_s16(filters), 0); @@ -950,10 +1686,12 @@ void vpx_convolve8_avg_vert_neon(const uint8_t *src, ptrdiff_t src_stride, s5 = s9; s6 = s10; height -= 4; - } while (height > 0); + } while (height != 0); src += 8; dst += 8; w -= 8; - } while (w > 0); + } while (w != 0); } } + +#endif diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h similarity index 52% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h index 4f27da9d2f4e..857b6d54e227 100644 --- a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.h @@ -72,6 +72,107 @@ static INLINE void load_u8_16x8(const uint8_t *s, const ptrdiff_t p, *s7 = vld1q_u8(s); } +#if defined(__aarch64__) && defined(__ARM_FEATURE_DOTPROD) && \ + (__ARM_FEATURE_DOTPROD == 1) + +static INLINE int32x4_t convolve8_4_dot_partial(const int8x16_t samples_lo, + const int8x16_t samples_hi, + const int32x4_t correction, + const int8x8_t filters) { + /* Sample range-clamping and permutation are performed by the caller. */ + int32x4_t sum; + + /* Accumulate dot product into 'correction' to account for range clamp. */ + sum = vdotq_lane_s32(correction, samples_lo, filters, 0); + sum = vdotq_lane_s32(sum, samples_hi, filters, 1); + + /* Narrowing and packing is performed by the caller. */ + return sum; +} + +static INLINE int32x4_t convolve8_4_dot(uint8x16_t samples, + const int8x8_t filters, + const int32x4_t correction, + const uint8x16_t range_limit, + const uint8x16x2_t permute_tbl) { + int8x16_t clamped_samples, permuted_samples[2]; + int32x4_t sum; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + clamped_samples = vreinterpretq_s8_u8(vsubq_u8(samples, range_limit)); + + /* Permute samples ready for dot product. */ + /* { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6 } */ + permuted_samples[0] = vqtbl1q_s8(clamped_samples, permute_tbl.val[0]); + /* { 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10 } */ + permuted_samples[1] = vqtbl1q_s8(clamped_samples, permute_tbl.val[1]); + + /* Accumulate dot product into 'correction' to account for range clamp. */ + sum = vdotq_lane_s32(correction, permuted_samples[0], filters, 0); + sum = vdotq_lane_s32(sum, permuted_samples[1], filters, 1); + + /* Narrowing and packing is performed by the caller. */ + return sum; +} + +static INLINE uint8x8_t convolve8_8_dot_partial(const int8x16_t samples0_lo, + const int8x16_t samples0_hi, + const int8x16_t samples1_lo, + const int8x16_t samples1_hi, + const int32x4_t correction, + const int8x8_t filters) { + /* Sample range-clamping and permutation are performed by the caller. */ + int32x4_t sum0, sum1; + int16x8_t sum; + + /* Accumulate dot product into 'correction' to account for range clamp. */ + /* First 4 output values. */ + sum0 = vdotq_lane_s32(correction, samples0_lo, filters, 0); + sum0 = vdotq_lane_s32(sum0, samples0_hi, filters, 1); + /* Second 4 output values. */ + sum1 = vdotq_lane_s32(correction, samples1_lo, filters, 0); + sum1 = vdotq_lane_s32(sum1, samples1_hi, filters, 1); + + /* Narrow and re-pack. */ + sum = vcombine_s16(vqmovn_s32(sum0), vqmovn_s32(sum1)); + return vqrshrun_n_s16(sum, 7); +} + +static INLINE uint8x8_t convolve8_8_dot(uint8x16_t samples, + const int8x8_t filters, + const int32x4_t correction, + const uint8x16_t range_limit, + const uint8x16x3_t permute_tbl) { + int8x16_t clamped_samples, permuted_samples[3]; + int32x4_t sum0, sum1; + int16x8_t sum; + + /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */ + clamped_samples = vreinterpretq_s8_u8(vsubq_u8(samples, range_limit)); + + /* Permute samples ready for dot product. */ + /* { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6 } */ + permuted_samples[0] = vqtbl1q_s8(clamped_samples, permute_tbl.val[0]); + /* { 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10 } */ + permuted_samples[1] = vqtbl1q_s8(clamped_samples, permute_tbl.val[1]); + /* { 8, 9, 10, 11, 9, 10, 11, 12, 10, 11, 12, 13, 11, 12, 13, 14 } */ + permuted_samples[2] = vqtbl1q_s8(clamped_samples, permute_tbl.val[2]); + + /* Accumulate dot product into 'correction' to account for range clamp. */ + /* First 4 output values. */ + sum0 = vdotq_lane_s32(correction, permuted_samples[0], filters, 0); + sum0 = vdotq_lane_s32(sum0, permuted_samples[1], filters, 1); + /* Second 4 output values. */ + sum1 = vdotq_lane_s32(correction, permuted_samples[1], filters, 0); + sum1 = vdotq_lane_s32(sum1, permuted_samples[2], filters, 1); + + /* Narrow and re-pack. */ + sum = vcombine_s16(vqmovn_s32(sum0), vqmovn_s32(sum1)); + return vqrshrun_n_s16(sum, 7); +} + +#endif + static INLINE int16x4_t convolve8_4(const int16x4_t s0, const int16x4_t s1, const int16x4_t s2, const int16x4_t s3, const int16x4_t s4, const int16x4_t s5, diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.h b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.h similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.h rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.h diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type1_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type1_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type1_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type1_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type2_neon.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type2_neon.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type2_neon.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_vert_filter_type2_neon.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c similarity index 97% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c index 07349d03ae57..8e3ee599f4fe 100644 --- a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c @@ -43,7 +43,7 @@ void vpx_convolve_avg_neon(const uint8_t *src, ptrdiff_t src_stride, vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(dd0), 1); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w == 8) { // avg8 uint8x8_t s0, s1, d0, d1; uint8x16_t s01, d01; @@ -64,7 +64,7 @@ void vpx_convolve_avg_neon(const uint8_t *src, ptrdiff_t src_stride, vst1_u8(dst, vget_high_u8(d01)); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w < 32) { // avg16 uint8x16_t s0, s1, d0, d1; do { @@ -83,7 +83,7 @@ void vpx_convolve_avg_neon(const uint8_t *src, ptrdiff_t src_stride, vst1q_u8(dst, d1); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w == 32) { // avg32 uint8x16_t s0, s1, s2, s3, d0, d1, d2, d3; do { @@ -110,7 +110,7 @@ void vpx_convolve_avg_neon(const uint8_t *src, ptrdiff_t src_stride, vst1q_u8(dst + 16, d3); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else { // avg64 uint8x16_t s0, s1, s2, s3, d0, d1, d2, d3; do { diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c similarity index 96% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c index 7abed67a4082..361ec8a806e9 100644 --- a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c +++ b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c @@ -33,7 +33,7 @@ void vpx_convolve_copy_neon(const uint8_t *src, ptrdiff_t src_stride, src += src_stride; dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w == 8) { // copy8 uint8x8_t s0, s1; do { @@ -47,7 +47,7 @@ void vpx_convolve_copy_neon(const uint8_t *src, ptrdiff_t src_stride, vst1_u8(dst, s1); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w < 32) { // copy16 uint8x16_t s0, s1; do { @@ -61,7 +61,7 @@ void vpx_convolve_copy_neon(const uint8_t *src, ptrdiff_t src_stride, vst1q_u8(dst, s1); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else if (w == 32) { // copy32 uint8x16_t s0, s1, s2, s3; do { @@ -79,7 +79,7 @@ void vpx_convolve_copy_neon(const uint8_t *src, ptrdiff_t src_stride, vst1q_u8(dst + 16, s3); dst += dst_stride; h -= 2; - } while (h > 0); + } while (h != 0); } else { // copy64 uint8x16_t s0, s1, s2, s3; do { diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_convolve_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_convolve_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c diff --git a/third_party/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c b/third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c similarity index 100% rename from third_party/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c rename to third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c diff --git a/third_party/libvpx/vpx_dsp/avg.c b/third_party/libvpx/source/libvpx/vpx_dsp/avg.c similarity index 100% rename from third_party/libvpx/vpx_dsp/avg.c rename to third_party/libvpx/source/libvpx/vpx_dsp/avg.c diff --git a/third_party/libvpx/vpx_dsp/bitreader.c b/third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c similarity index 100% rename from third_party/libvpx/vpx_dsp/bitreader.c rename to third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c diff --git a/third_party/libvpx/vpx_dsp/bitreader.h b/third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h similarity index 100% rename from third_party/libvpx/vpx_dsp/bitreader.h rename to third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h diff --git a/third_party/libvpx/vpx_dsp/bitreader_buffer.c b/third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c similarity index 100% rename from third_party/libvpx/vpx_dsp/bitreader_buffer.c rename to third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c diff --git a/third_party/libvpx/vpx_dsp/bitreader_buffer.h b/third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h similarity index 100% rename from third_party/libvpx/vpx_dsp/bitreader_buffer.h rename to third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h diff --git a/third_party/libvpx/vpx_dsp/bitwriter.c b/third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.c similarity index 100% rename from third_party/libvpx/vpx_dsp/bitwriter.c rename to third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.c diff --git a/third_party/libvpx/vpx_dsp/bitwriter.h b/third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h similarity index 100% rename from third_party/libvpx/vpx_dsp/bitwriter.h rename to third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h diff --git a/third_party/libvpx/vpx_dsp/bitwriter_buffer.c b/third_party/libvpx/source/libvpx/vpx_dsp/bitwriter_buffer.c similarity index 100% rename from third_party/libvpx/vpx_dsp/bitwriter_buffer.c rename to third_party/libvpx/source/libvpx/vpx_dsp/bitwriter_buffer.c diff --git a/third_party/libvpx/vpx_dsp/bitwriter_buffer.h b/third_party/libvpx/source/libvpx/vpx_dsp/bitwriter_buffer.h similarity index 100% rename from third_party/libvpx/vpx_dsp/bitwriter_buffer.h rename to third_party/libvpx/source/libvpx/vpx_dsp/bitwriter_buffer.h diff --git a/third_party/libvpx/vpx_dsp/deblock.c b/third_party/libvpx/source/libvpx/vpx_dsp/deblock.c similarity index 100% rename from third_party/libvpx/vpx_dsp/deblock.c rename to third_party/libvpx/source/libvpx/vpx_dsp/deblock.c diff --git a/third_party/libvpx/vpx_dsp/fastssim.c b/third_party/libvpx/source/libvpx/vpx_dsp/fastssim.c similarity index 100% rename from third_party/libvpx/vpx_dsp/fastssim.c rename to third_party/libvpx/source/libvpx/vpx_dsp/fastssim.c diff --git a/third_party/libvpx/vpx_dsp/fwd_txfm.c b/third_party/libvpx/source/libvpx/vpx_dsp/fwd_txfm.c similarity index 100% rename from third_party/libvpx/vpx_dsp/fwd_txfm.c rename to third_party/libvpx/source/libvpx/vpx_dsp/fwd_txfm.c diff --git a/third_party/libvpx/vpx_dsp/fwd_txfm.h b/third_party/libvpx/source/libvpx/vpx_dsp/fwd_txfm.h similarity index 100% rename from third_party/libvpx/vpx_dsp/fwd_txfm.h rename to third_party/libvpx/source/libvpx/vpx_dsp/fwd_txfm.h diff --git a/third_party/libvpx/vpx_dsp/intrapred.c b/third_party/libvpx/source/libvpx/vpx_dsp/intrapred.c similarity index 100% rename from third_party/libvpx/vpx_dsp/intrapred.c rename to third_party/libvpx/source/libvpx/vpx_dsp/intrapred.c diff --git a/third_party/libvpx/vpx_dsp/inv_txfm.c b/third_party/libvpx/source/libvpx/vpx_dsp/inv_txfm.c similarity index 100% rename from third_party/libvpx/vpx_dsp/inv_txfm.c rename to third_party/libvpx/source/libvpx/vpx_dsp/inv_txfm.c diff --git a/third_party/libvpx/vpx_dsp/inv_txfm.h b/third_party/libvpx/source/libvpx/vpx_dsp/inv_txfm.h similarity index 100% rename from third_party/libvpx/vpx_dsp/inv_txfm.h rename to third_party/libvpx/source/libvpx/vpx_dsp/inv_txfm.h diff --git a/third_party/libvpx/vpx_dsp/loopfilter.c b/third_party/libvpx/source/libvpx/vpx_dsp/loopfilter.c similarity index 100% rename from third_party/libvpx/vpx_dsp/loopfilter.c rename to third_party/libvpx/source/libvpx/vpx_dsp/loopfilter.c diff --git a/third_party/libvpx/vpx_dsp/mips/add_noise_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/add_noise_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/add_noise_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/add_noise_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/avg_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/avg_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/avg_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/avg_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/common_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/common_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/common_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/common_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/common_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/common_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/common_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/common_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/convolve2_avg_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_avg_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve2_avg_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_avg_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve2_avg_horiz_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_avg_horiz_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve2_avg_horiz_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_avg_horiz_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve2_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve2_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve2_horiz_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_horiz_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve2_horiz_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_horiz_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve2_vert_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_vert_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve2_vert_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve2_vert_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve8_avg_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_avg_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve8_avg_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_avg_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve8_avg_horiz_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_avg_horiz_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve8_avg_horiz_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_avg_horiz_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve8_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve8_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve8_horiz_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_horiz_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve8_horiz_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_horiz_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve8_vert_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_vert_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve8_vert_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve8_vert_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/convolve_common_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve_common_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/convolve_common_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/convolve_common_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/deblock_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/deblock_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/deblock_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/deblock_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/fwd_txfm_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_txfm_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/fwd_txfm_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_txfm_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/fwd_txfm_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_txfm_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/fwd_txfm_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/fwd_txfm_msa.h diff --git a/third_party/libvpx/vpx_dsp/mips/idct16x16_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/idct16x16_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/idct16x16_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/idct16x16_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/idct32x32_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/idct32x32_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/idct32x32_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/idct32x32_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/idct4x4_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/idct4x4_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/idct4x4_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/idct4x4_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/idct8x8_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/idct8x8_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/idct8x8_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/idct8x8_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/intrapred16_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred16_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/intrapred16_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred16_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/intrapred4_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred4_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/intrapred4_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred4_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/intrapred8_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred8_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/intrapred8_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred8_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/intrapred_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/intrapred_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/intrapred_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/inv_txfm_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/inv_txfm_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/inv_txfm_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/inv_txfm_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/inv_txfm_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/inv_txfm_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/inv_txfm_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/inv_txfm_msa.h diff --git a/third_party/libvpx/vpx_dsp/mips/itrans16_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans16_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/itrans16_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans16_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/itrans32_cols_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans32_cols_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/itrans32_cols_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans32_cols_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/itrans32_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans32_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/itrans32_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans32_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/itrans4_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans4_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/itrans4_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans4_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/itrans8_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans8_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/itrans8_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/itrans8_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_16_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_16_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_16_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_16_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_4_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_4_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_4_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_4_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_8_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_8_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_8_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_8_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_filters_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_macros_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_macros_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_macros_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_macros_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_masks_dspr2.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_masks_dspr2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_masks_dspr2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_masks_dspr2.h diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_mb_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_mb_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_mb_horiz_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_horiz_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_mb_horiz_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_horiz_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_mb_vert_dspr2.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_vert_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_mb_vert_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_mb_vert_dspr2.c diff --git a/third_party/libvpx/vpx_dsp/mips/loopfilter_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/loopfilter_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/loopfilter_msa.h diff --git a/third_party/libvpx/vpx_dsp/mips/macros_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/macros_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/macros_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/macros_msa.h diff --git a/third_party/libvpx/vpx_dsp/mips/sad_mmi.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/sad_mmi.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/sad_mmi.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/sad_mmi.c diff --git a/third_party/libvpx/vpx_dsp/mips/sad_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/sad_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/sad_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/sad_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/sub_pixel_variance_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/sub_pixel_variance_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/sub_pixel_variance_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/sub_pixel_variance_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/subtract_mmi.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/subtract_mmi.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/subtract_mmi.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/subtract_mmi.c diff --git a/third_party/libvpx/vpx_dsp/mips/subtract_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/subtract_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/subtract_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/subtract_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/sum_squares_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/sum_squares_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/sum_squares_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/sum_squares_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/txfm_macros_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/txfm_macros_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/txfm_macros_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/txfm_macros_msa.h diff --git a/third_party/libvpx/vpx_dsp/mips/variance_mmi.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/variance_mmi.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/variance_mmi.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/variance_mmi.c diff --git a/third_party/libvpx/vpx_dsp/mips/variance_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/variance_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/variance_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/variance_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_horiz_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_horiz_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_horiz_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_horiz_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_vert_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_vert_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_avg_vert_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_avg_vert_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_horiz_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_horiz_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_horiz_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_horiz_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_mmi.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_mmi.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_mmi.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_mmi.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c diff --git a/third_party/libvpx/vpx_dsp/mips/vpx_convolve_msa.h b/third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_msa.h similarity index 100% rename from third_party/libvpx/vpx_dsp/mips/vpx_convolve_msa.h rename to third_party/libvpx/source/libvpx/vpx_dsp/mips/vpx_convolve_msa.h diff --git a/third_party/libvpx/vpx_dsp/postproc.h b/third_party/libvpx/source/libvpx/vpx_dsp/postproc.h similarity index 100% rename from third_party/libvpx/vpx_dsp/postproc.h rename to third_party/libvpx/source/libvpx/vpx_dsp/postproc.h diff --git a/third_party/libvpx/vpx_dsp/ppc/bitdepth_conversion_vsx.h b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/bitdepth_conversion_vsx.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/bitdepth_conversion_vsx.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/bitdepth_conversion_vsx.h diff --git a/third_party/libvpx/vpx_dsp/ppc/deblock_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/deblock_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/deblock_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/deblock_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/hadamard_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/hadamard_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/hadamard_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/hadamard_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/intrapred_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/intrapred_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/inv_txfm_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/inv_txfm_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/inv_txfm_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/inv_txfm_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/inv_txfm_vsx.h b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/inv_txfm_vsx.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/inv_txfm_vsx.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/inv_txfm_vsx.h diff --git a/third_party/libvpx/vpx_dsp/ppc/quantize_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/quantize_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/sad_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/sad_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/sad_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/sad_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/subtract_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/subtract_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/subtract_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/subtract_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/transpose_vsx.h b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/transpose_vsx.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/transpose_vsx.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/transpose_vsx.h diff --git a/third_party/libvpx/vpx_dsp/ppc/txfm_common_vsx.h b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/txfm_common_vsx.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/txfm_common_vsx.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/txfm_common_vsx.h diff --git a/third_party/libvpx/vpx_dsp/ppc/types_vsx.h b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/types_vsx.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/types_vsx.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/types_vsx.h diff --git a/third_party/libvpx/vpx_dsp/ppc/variance_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/variance_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/variance_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/variance_vsx.c diff --git a/third_party/libvpx/vpx_dsp/ppc/vpx_convolve_vsx.c b/third_party/libvpx/source/libvpx/vpx_dsp/ppc/vpx_convolve_vsx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ppc/vpx_convolve_vsx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ppc/vpx_convolve_vsx.c diff --git a/third_party/libvpx/vpx_dsp/prob.c b/third_party/libvpx/source/libvpx/vpx_dsp/prob.c similarity index 100% rename from third_party/libvpx/vpx_dsp/prob.c rename to third_party/libvpx/source/libvpx/vpx_dsp/prob.c diff --git a/third_party/libvpx/vpx_dsp/prob.h b/third_party/libvpx/source/libvpx/vpx_dsp/prob.h similarity index 100% rename from third_party/libvpx/vpx_dsp/prob.h rename to third_party/libvpx/source/libvpx/vpx_dsp/prob.h diff --git a/third_party/libvpx/vpx_dsp/psnr.c b/third_party/libvpx/source/libvpx/vpx_dsp/psnr.c similarity index 100% rename from third_party/libvpx/vpx_dsp/psnr.c rename to third_party/libvpx/source/libvpx/vpx_dsp/psnr.c diff --git a/third_party/libvpx/vpx_dsp/psnr.h b/third_party/libvpx/source/libvpx/vpx_dsp/psnr.h similarity index 100% rename from third_party/libvpx/vpx_dsp/psnr.h rename to third_party/libvpx/source/libvpx/vpx_dsp/psnr.h diff --git a/third_party/libvpx/vpx_dsp/psnrhvs.c b/third_party/libvpx/source/libvpx/vpx_dsp/psnrhvs.c similarity index 100% rename from third_party/libvpx/vpx_dsp/psnrhvs.c rename to third_party/libvpx/source/libvpx/vpx_dsp/psnrhvs.c diff --git a/third_party/libvpx/vpx_dsp/quantize.c b/third_party/libvpx/source/libvpx/vpx_dsp/quantize.c similarity index 100% rename from third_party/libvpx/vpx_dsp/quantize.c rename to third_party/libvpx/source/libvpx/vpx_dsp/quantize.c diff --git a/third_party/libvpx/vpx_dsp/quantize.h b/third_party/libvpx/source/libvpx/vpx_dsp/quantize.h similarity index 100% rename from third_party/libvpx/vpx_dsp/quantize.h rename to third_party/libvpx/source/libvpx/vpx_dsp/quantize.h diff --git a/third_party/libvpx/vpx_dsp/sad.c b/third_party/libvpx/source/libvpx/vpx_dsp/sad.c similarity index 100% rename from third_party/libvpx/vpx_dsp/sad.c rename to third_party/libvpx/source/libvpx/vpx_dsp/sad.c diff --git a/third_party/libvpx/vpx_dsp/skin_detection.c b/third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c similarity index 100% rename from third_party/libvpx/vpx_dsp/skin_detection.c rename to third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c diff --git a/third_party/libvpx/vpx_dsp/skin_detection.h b/third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.h similarity index 100% rename from third_party/libvpx/vpx_dsp/skin_detection.h rename to third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.h diff --git a/third_party/libvpx/vpx_dsp/ssim.c b/third_party/libvpx/source/libvpx/vpx_dsp/ssim.c similarity index 100% rename from third_party/libvpx/vpx_dsp/ssim.c rename to third_party/libvpx/source/libvpx/vpx_dsp/ssim.c diff --git a/third_party/libvpx/vpx_dsp/ssim.h b/third_party/libvpx/source/libvpx/vpx_dsp/ssim.h similarity index 100% rename from third_party/libvpx/vpx_dsp/ssim.h rename to third_party/libvpx/source/libvpx/vpx_dsp/ssim.h diff --git a/third_party/libvpx/vpx_dsp/subtract.c b/third_party/libvpx/source/libvpx/vpx_dsp/subtract.c similarity index 100% rename from third_party/libvpx/vpx_dsp/subtract.c rename to third_party/libvpx/source/libvpx/vpx_dsp/subtract.c diff --git a/third_party/libvpx/vpx_dsp/sum_squares.c b/third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c similarity index 100% rename from third_party/libvpx/vpx_dsp/sum_squares.c rename to third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c diff --git a/third_party/libvpx/vpx_dsp/txfm_common.h b/third_party/libvpx/source/libvpx/vpx_dsp/txfm_common.h similarity index 100% rename from third_party/libvpx/vpx_dsp/txfm_common.h rename to third_party/libvpx/source/libvpx/vpx_dsp/txfm_common.h diff --git a/third_party/libvpx/vpx_dsp/variance.c b/third_party/libvpx/source/libvpx/vpx_dsp/variance.c similarity index 100% rename from third_party/libvpx/vpx_dsp/variance.c rename to third_party/libvpx/source/libvpx/vpx_dsp/variance.c diff --git a/third_party/libvpx/vpx_dsp/variance.h b/third_party/libvpx/source/libvpx/vpx_dsp/variance.h similarity index 100% rename from third_party/libvpx/vpx_dsp/variance.h rename to third_party/libvpx/source/libvpx/vpx_dsp/variance.h diff --git a/third_party/libvpx/vpx_dsp/vpx_convolve.c b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_convolve.c rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c diff --git a/third_party/libvpx/vpx_dsp/vpx_convolve.h b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.h similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_convolve.h rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.h diff --git a/third_party/libvpx/vpx_dsp/vpx_dsp.mk b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_dsp.mk rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk diff --git a/third_party/libvpx/vpx_dsp/vpx_dsp_common.h b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_dsp_common.h rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h diff --git a/third_party/libvpx/vpx_dsp/vpx_dsp_rtcd.c b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_dsp_rtcd.c rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c diff --git a/third_party/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl diff --git a/third_party/libvpx/vpx_dsp/vpx_filter.h b/third_party/libvpx/source/libvpx/vpx_dsp/vpx_filter.h similarity index 100% rename from third_party/libvpx/vpx_dsp/vpx_filter.h rename to third_party/libvpx/source/libvpx/vpx_dsp/vpx_filter.h diff --git a/third_party/libvpx/vpx_dsp/x86/add_noise_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/add_noise_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/add_noise_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/add_noise_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/avg_intrin_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/avg_intrin_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/avg_intrin_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/avg_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/avg_pred_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_pred_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/avg_pred_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_pred_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/avg_ssse3_x86_64.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_ssse3_x86_64.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/avg_ssse3_x86_64.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_ssse3_x86_64.asm diff --git a/third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_avx2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_avx2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_avx2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_avx2.h diff --git a/third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/convolve.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/convolve.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve.h diff --git a/third_party/libvpx/vpx_dsp/x86/convolve_avx2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_avx2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/convolve_avx2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_avx2.h diff --git a/third_party/libvpx/vpx_dsp/x86/convolve_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/convolve_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/convolve_ssse3.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_ssse3.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/convolve_ssse3.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/convolve_ssse3.h diff --git a/third_party/libvpx/vpx_dsp/x86/deblock_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/deblock_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/deblock_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/deblock_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_avx2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_avx2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_avx2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_avx2.h diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_dct32x32_impl_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_txfm_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_txfm_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_txfm_impl_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_impl_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_txfm_impl_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_impl_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_txfm_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_txfm_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_txfm_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_txfm_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/fwd_txfm_ssse3_x86_64.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_ssse3_x86_64.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/fwd_txfm_ssse3_x86_64.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/fwd_txfm_ssse3_x86_64.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse4.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse4.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse4.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct16x16_add_sse4.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_ssse3.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_ssse3.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_ssse3.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_intrin_ssse3.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_intrapred_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_intrapred_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_intrapred_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse4.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse4.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse4.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_inv_txfm_sse4.h diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_loopfilter_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_loopfilter_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_loopfilter_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_loopfilter_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_quantize_intrin_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_quantize_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_quantize_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_quantize_intrin_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_sad4d_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad4d_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_sad4d_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad4d_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_sad_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_sad_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_subpel_variance_impl_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_subpel_variance_impl_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_subpel_variance_impl_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_subpel_variance_impl_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_variance_impl_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_variance_impl_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_variance_impl_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_variance_impl_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/highbd_variance_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_variance_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/highbd_variance_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_variance_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/intrapred_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/intrapred_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/intrapred_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/intrapred_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/intrapred_ssse3.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/intrapred_ssse3.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/intrapred_ssse3.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/intrapred_ssse3.asm diff --git a/third_party/libvpx/vpx_dsp/x86/inv_txfm_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/inv_txfm_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/inv_txfm_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/inv_txfm_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/inv_txfm_ssse3.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_ssse3.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/inv_txfm_ssse3.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_ssse3.c diff --git a/third_party/libvpx/vpx_dsp/x86/inv_txfm_ssse3.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_ssse3.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/inv_txfm_ssse3.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_ssse3.h diff --git a/third_party/libvpx/vpx_dsp/x86/inv_wht_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_wht_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/inv_wht_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_wht_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/loopfilter_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/loopfilter_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/loopfilter_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/loopfilter_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/mem_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/mem_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/mem_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/mem_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/post_proc_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/post_proc_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/post_proc_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/post_proc_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/quantize_avx.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/quantize_avx.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c diff --git a/third_party/libvpx/vpx_dsp/x86/quantize_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/quantize_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/quantize_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/quantize_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/quantize_ssse3.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_ssse3.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/quantize_ssse3.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_ssse3.c diff --git a/third_party/libvpx/vpx_dsp/x86/quantize_ssse3.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_ssse3.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/quantize_ssse3.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_ssse3.h diff --git a/third_party/libvpx/vpx_dsp/x86/sad4d_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad4d_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/sad4d_avx512.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx512.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad4d_avx512.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx512.c diff --git a/third_party/libvpx/vpx_dsp/x86/sad4d_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad4d_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/sad_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/sad_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/sad_sse3.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse3.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad_sse3.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse3.asm diff --git a/third_party/libvpx/vpx_dsp/x86/sad_sse4.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse4.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad_sse4.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_sse4.asm diff --git a/third_party/libvpx/vpx_dsp/x86/sad_ssse3.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_ssse3.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sad_ssse3.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_ssse3.asm diff --git a/third_party/libvpx/vpx_dsp/x86/ssim_opt_x86_64.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/ssim_opt_x86_64.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/ssim_opt_x86_64.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/ssim_opt_x86_64.asm diff --git a/third_party/libvpx/vpx_dsp/x86/subpel_variance_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/subpel_variance_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/subpel_variance_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/subpel_variance_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/subtract_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/subtract_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/subtract_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/subtract_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/sum_squares_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/sum_squares_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/sum_squares_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/sum_squares_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/transpose_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/transpose_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/transpose_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/transpose_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/txfm_common_sse2.h b/third_party/libvpx/source/libvpx/vpx_dsp/x86/txfm_common_sse2.h similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/txfm_common_sse2.h rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/txfm_common_sse2.h diff --git a/third_party/libvpx/vpx_dsp/x86/variance_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/variance_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/variance_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/variance_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_convolve_copy_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_convolve_copy_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_convolve_copy_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_convolve_copy_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_high_subpixel_8t_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_high_subpixel_8t_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_high_subpixel_8t_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_high_subpixel_8t_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_high_subpixel_bilinear_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_high_subpixel_bilinear_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_high_subpixel_bilinear_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_high_subpixel_bilinear_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_4t_intrin_sse2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_4t_intrin_sse2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_4t_intrin_sse2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_4t_intrin_sse2.c diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm diff --git a/third_party/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm b/third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm similarity index 100% rename from third_party/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm rename to third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm diff --git a/third_party/libvpx/vpx_mem/include/vpx_mem_intrnl.h b/third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h similarity index 100% rename from third_party/libvpx/vpx_mem/include/vpx_mem_intrnl.h rename to third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h diff --git a/third_party/libvpx/vpx_mem/vpx_mem.c b/third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c similarity index 100% rename from third_party/libvpx/vpx_mem/vpx_mem.c rename to third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c diff --git a/third_party/libvpx/vpx_mem/vpx_mem.h b/third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h similarity index 100% rename from third_party/libvpx/vpx_mem/vpx_mem.h rename to third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h diff --git a/third_party/libvpx/vpx_mem/vpx_mem.mk b/third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.mk similarity index 100% rename from third_party/libvpx/vpx_mem/vpx_mem.mk rename to third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.mk diff --git a/third_party/libvpx/vpx_ports/arm.h b/third_party/libvpx/source/libvpx/vpx_ports/arm.h similarity index 100% rename from third_party/libvpx/vpx_ports/arm.h rename to third_party/libvpx/source/libvpx/vpx_ports/arm.h diff --git a/third_party/libvpx/vpx_ports/arm_cpudetect.c b/third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c similarity index 100% rename from third_party/libvpx/vpx_ports/arm_cpudetect.c rename to third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c diff --git a/third_party/libvpx/vpx_ports/asmdefs_mmi.h b/third_party/libvpx/source/libvpx/vpx_ports/asmdefs_mmi.h similarity index 100% rename from third_party/libvpx/vpx_ports/asmdefs_mmi.h rename to third_party/libvpx/source/libvpx/vpx_ports/asmdefs_mmi.h diff --git a/third_party/libvpx/vpx_ports/bitops.h b/third_party/libvpx/source/libvpx/vpx_ports/bitops.h similarity index 100% rename from third_party/libvpx/vpx_ports/bitops.h rename to third_party/libvpx/source/libvpx/vpx_ports/bitops.h diff --git a/third_party/libvpx/vpx_ports/compiler_attributes.h b/third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h similarity index 100% rename from third_party/libvpx/vpx_ports/compiler_attributes.h rename to third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h diff --git a/third_party/libvpx/vpx_ports/emmintrin_compat.h b/third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h similarity index 100% rename from third_party/libvpx/vpx_ports/emmintrin_compat.h rename to third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h diff --git a/third_party/libvpx/vpx_ports/emms_mmx.asm b/third_party/libvpx/source/libvpx/vpx_ports/emms_mmx.asm similarity index 100% rename from third_party/libvpx/vpx_ports/emms_mmx.asm rename to third_party/libvpx/source/libvpx/vpx_ports/emms_mmx.asm diff --git a/third_party/libvpx/vpx_ports/emms_mmx.c b/third_party/libvpx/source/libvpx/vpx_ports/emms_mmx.c similarity index 100% rename from third_party/libvpx/vpx_ports/emms_mmx.c rename to third_party/libvpx/source/libvpx/vpx_ports/emms_mmx.c diff --git a/third_party/libvpx/vpx_ports/float_control_word.asm b/third_party/libvpx/source/libvpx/vpx_ports/float_control_word.asm similarity index 100% rename from third_party/libvpx/vpx_ports/float_control_word.asm rename to third_party/libvpx/source/libvpx/vpx_ports/float_control_word.asm diff --git a/third_party/libvpx/vpx_ports/mem.h b/third_party/libvpx/source/libvpx/vpx_ports/mem.h similarity index 100% rename from third_party/libvpx/vpx_ports/mem.h rename to third_party/libvpx/source/libvpx/vpx_ports/mem.h diff --git a/third_party/libvpx/vpx_ports/mem_ops.h b/third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h similarity index 100% rename from third_party/libvpx/vpx_ports/mem_ops.h rename to third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h diff --git a/third_party/libvpx/vpx_ports/mem_ops_aligned.h b/third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h similarity index 100% rename from third_party/libvpx/vpx_ports/mem_ops_aligned.h rename to third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h diff --git a/third_party/libvpx/source/libvpx/vpx_ports/mips.h b/third_party/libvpx/source/libvpx/vpx_ports/mips.h new file mode 100644 index 000000000000..bdc7525f7be4 --- /dev/null +++ b/third_party/libvpx/source/libvpx/vpx_ports/mips.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VPX_PORTS_MIPS_H_ +#define VPX_PORTS_MIPS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define HAS_MMI 0x01 +#define HAS_MSA 0x02 + +int mips_cpu_caps(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // VPX_PORTS_MIPS_H_ diff --git a/third_party/libvpx/source/libvpx/vpx_ports/mips_cpudetect.c b/third_party/libvpx/source/libvpx/vpx_ports/mips_cpudetect.c new file mode 100644 index 000000000000..e0eca2d48deb --- /dev/null +++ b/third_party/libvpx/source/libvpx/vpx_ports/mips_cpudetect.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include +#include +#include "./vpx_config.h" +#include "vpx_ports/mips.h" + +#if CONFIG_RUNTIME_CPU_DETECT +#if defined(__mips__) && defined(__linux__) +int mips_cpu_caps(void) { + char cpuinfo_line[512]; + int flag = 0x0; + FILE *f = fopen("/proc/cpuinfo", "r"); + if (!f) { + // Assume nothing if /proc/cpuinfo is unavailable. + // This will occur for Chrome sandbox for Pepper or Render process. + return 0; + } + while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { + if (memcmp(cpuinfo_line, "cpu model", 9) == 0) { + // Workaround early kernel without mmi in ASEs line. + if (strstr(cpuinfo_line, "Loongson-3")) { + flag |= HAS_MMI; + } else if (strstr(cpuinfo_line, "Loongson-2K")) { + flag |= HAS_MMI | HAS_MSA; + } + } + if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) { + if (strstr(cpuinfo_line, "loongson-mmi") && + strstr(cpuinfo_line, "loongson-ext")) { + flag |= HAS_MMI; + } + if (strstr(cpuinfo_line, "msa")) { + flag |= HAS_MSA; + } + // ASEs is the last line, so we can break here. + break; + } + } + fclose(f); + return flag; +} +#else /* end __mips__ && __linux__ */ +#error \ + "--enable-runtime-cpu-detect selected, but no CPU detection method " \ +"available for your platform. Reconfigure with --disable-runtime-cpu-detect." +#endif +#else /* end CONFIG_RUNTIME_CPU_DETECT */ +int mips_cpu_caps(void) { return 0; } +#endif diff --git a/third_party/libvpx/vpx_ports/msvc.h b/third_party/libvpx/source/libvpx/vpx_ports/msvc.h similarity index 100% rename from third_party/libvpx/vpx_ports/msvc.h rename to third_party/libvpx/source/libvpx/vpx_ports/msvc.h diff --git a/third_party/libvpx/vpx_ports/ppc.h b/third_party/libvpx/source/libvpx/vpx_ports/ppc.h similarity index 100% rename from third_party/libvpx/vpx_ports/ppc.h rename to third_party/libvpx/source/libvpx/vpx_ports/ppc.h diff --git a/third_party/libvpx/vpx_ports/ppc_cpudetect.c b/third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c similarity index 100% rename from third_party/libvpx/vpx_ports/ppc_cpudetect.c rename to third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c diff --git a/third_party/libvpx/vpx_ports/static_assert.h b/third_party/libvpx/source/libvpx/vpx_ports/static_assert.h similarity index 100% rename from third_party/libvpx/vpx_ports/static_assert.h rename to third_party/libvpx/source/libvpx/vpx_ports/static_assert.h diff --git a/third_party/libvpx/vpx_ports/system_state.h b/third_party/libvpx/source/libvpx/vpx_ports/system_state.h similarity index 100% rename from third_party/libvpx/vpx_ports/system_state.h rename to third_party/libvpx/source/libvpx/vpx_ports/system_state.h diff --git a/third_party/libvpx/vpx_ports/vpx_once.h b/third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h similarity index 100% rename from third_party/libvpx/vpx_ports/vpx_once.h rename to third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h diff --git a/third_party/libvpx/vpx_ports/vpx_ports.mk b/third_party/libvpx/source/libvpx/vpx_ports/vpx_ports.mk similarity index 93% rename from third_party/libvpx/vpx_ports/vpx_ports.mk rename to third_party/libvpx/source/libvpx/vpx_ports/vpx_ports.mk index 2331773693f4..e5001be49674 100644 --- a/third_party/libvpx/vpx_ports/vpx_ports.mk +++ b/third_party/libvpx/source/libvpx/vpx_ports/vpx_ports.mk @@ -42,6 +42,9 @@ PORTS_SRCS-$(VPX_ARCH_ARM) += arm.h PORTS_SRCS-$(VPX_ARCH_PPC) += ppc_cpudetect.c PORTS_SRCS-$(VPX_ARCH_PPC) += ppc.h +PORTS_SRCS-$(VPX_ARCH_MIPS) += mips_cpudetect.c +PORTS_SRCS-$(VPX_ARCH_MIPS) += mips.h + ifeq ($(VPX_ARCH_MIPS), yes) PORTS_SRCS-yes += asmdefs_mmi.h endif diff --git a/third_party/libvpx/vpx_ports/vpx_timer.h b/third_party/libvpx/source/libvpx/vpx_ports/vpx_timer.h similarity index 100% rename from third_party/libvpx/vpx_ports/vpx_timer.h rename to third_party/libvpx/source/libvpx/vpx_ports/vpx_timer.h diff --git a/third_party/libvpx/vpx_ports/x86.h b/third_party/libvpx/source/libvpx/vpx_ports/x86.h similarity index 95% rename from third_party/libvpx/vpx_ports/x86.h rename to third_party/libvpx/source/libvpx/vpx_ports/x86.h index 14f434449588..4d5391b78ddf 100644 --- a/third_party/libvpx/vpx_ports/x86.h +++ b/third_party/libvpx/source/libvpx/vpx_ports/x86.h @@ -223,6 +223,8 @@ static INLINE int x86_simd_caps(void) { } } + (void)reg_eax; // Avoid compiler warning on unused-but-set variable. + return flags & mask; } @@ -240,7 +242,7 @@ static INLINE int x86_simd_caps(void) { // x86_readtsc directly, but prevent the CPU's out-of-order execution from // affecting the measurement (by having earlier/later instructions be evaluated // in the time interval). See the white paper, "How to Benchmark Code -// Execution Times on IntelĀ® IA-32 and IA-64 Instruction Set Architectures" by +// Execution Times on Intel(R) IA-32 and IA-64 Instruction Set Architectures" by // Gabriele Paoloni for more information. // // If you are timing a large function (CPU time > a couple of seconds), use @@ -306,14 +308,26 @@ static INLINE unsigned int x86_readtscp(void) { static INLINE unsigned int x86_tsc_start(void) { unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx; + // This call should not be removed. See function notes above. cpuid(0, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); + // Avoid compiler warnings on unused-but-set variables. + (void)reg_eax; + (void)reg_ebx; + (void)reg_ecx; + (void)reg_edx; return x86_readtsc(); } static INLINE unsigned int x86_tsc_end(void) { uint32_t v = x86_readtscp(); unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx; + // This call should not be removed. See function notes above. cpuid(0, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); + // Avoid compiler warnings on unused-but-set variables. + (void)reg_eax; + (void)reg_ebx; + (void)reg_ecx; + (void)reg_edx; return v; } diff --git a/third_party/libvpx/vpx_ports/x86_abi_support.asm b/third_party/libvpx/source/libvpx/vpx_ports/x86_abi_support.asm similarity index 100% rename from third_party/libvpx/vpx_ports/x86_abi_support.asm rename to third_party/libvpx/source/libvpx/vpx_ports/x86_abi_support.asm diff --git a/third_party/libvpx/vpx_scale/generic/gen_scalers.c b/third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c similarity index 100% rename from third_party/libvpx/vpx_scale/generic/gen_scalers.c rename to third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c diff --git a/third_party/libvpx/vpx_scale/generic/vpx_scale.c b/third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c similarity index 100% rename from third_party/libvpx/vpx_scale/generic/vpx_scale.c rename to third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c diff --git a/third_party/libvpx/vpx_scale/generic/yv12config.c b/third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c similarity index 100% rename from third_party/libvpx/vpx_scale/generic/yv12config.c rename to third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c diff --git a/third_party/libvpx/vpx_scale/generic/yv12extend.c b/third_party/libvpx/source/libvpx/vpx_scale/generic/yv12extend.c similarity index 100% rename from third_party/libvpx/vpx_scale/generic/yv12extend.c rename to third_party/libvpx/source/libvpx/vpx_scale/generic/yv12extend.c diff --git a/third_party/libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c b/third_party/libvpx/source/libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c similarity index 100% rename from third_party/libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c rename to third_party/libvpx/source/libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c diff --git a/third_party/libvpx/vpx_scale/vpx_scale.h b/third_party/libvpx/source/libvpx/vpx_scale/vpx_scale.h similarity index 100% rename from third_party/libvpx/vpx_scale/vpx_scale.h rename to third_party/libvpx/source/libvpx/vpx_scale/vpx_scale.h diff --git a/third_party/libvpx/vpx_scale/vpx_scale.mk b/third_party/libvpx/source/libvpx/vpx_scale/vpx_scale.mk similarity index 100% rename from third_party/libvpx/vpx_scale/vpx_scale.mk rename to third_party/libvpx/source/libvpx/vpx_scale/vpx_scale.mk diff --git a/third_party/libvpx/vpx_scale/vpx_scale_rtcd.c b/third_party/libvpx/source/libvpx/vpx_scale/vpx_scale_rtcd.c similarity index 100% rename from third_party/libvpx/vpx_scale/vpx_scale_rtcd.c rename to third_party/libvpx/source/libvpx/vpx_scale/vpx_scale_rtcd.c diff --git a/third_party/libvpx/vpx_scale/vpx_scale_rtcd.pl b/third_party/libvpx/source/libvpx/vpx_scale/vpx_scale_rtcd.pl similarity index 100% rename from third_party/libvpx/vpx_scale/vpx_scale_rtcd.pl rename to third_party/libvpx/source/libvpx/vpx_scale/vpx_scale_rtcd.pl diff --git a/third_party/libvpx/vpx_scale/yv12config.h b/third_party/libvpx/source/libvpx/vpx_scale/yv12config.h similarity index 100% rename from third_party/libvpx/vpx_scale/yv12config.h rename to third_party/libvpx/source/libvpx/vpx_scale/yv12config.h diff --git a/third_party/libvpx/vpx_util/endian_inl.h b/third_party/libvpx/source/libvpx/vpx_util/endian_inl.h similarity index 100% rename from third_party/libvpx/vpx_util/endian_inl.h rename to third_party/libvpx/source/libvpx/vpx_util/endian_inl.h diff --git a/third_party/libvpx/vpx_util/vpx_atomics.h b/third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h similarity index 100% rename from third_party/libvpx/vpx_util/vpx_atomics.h rename to third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h diff --git a/third_party/libvpx/vpx_util/vpx_debug_util.c b/third_party/libvpx/source/libvpx/vpx_util/vpx_debug_util.c similarity index 100% rename from third_party/libvpx/vpx_util/vpx_debug_util.c rename to third_party/libvpx/source/libvpx/vpx_util/vpx_debug_util.c diff --git a/third_party/libvpx/vpx_util/vpx_debug_util.h b/third_party/libvpx/source/libvpx/vpx_util/vpx_debug_util.h similarity index 100% rename from third_party/libvpx/vpx_util/vpx_debug_util.h rename to third_party/libvpx/source/libvpx/vpx_util/vpx_debug_util.h diff --git a/third_party/libvpx/vpx_util/vpx_thread.c b/third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c similarity index 100% rename from third_party/libvpx/vpx_util/vpx_thread.c rename to third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c diff --git a/third_party/libvpx/vpx_util/vpx_thread.h b/third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h similarity index 100% rename from third_party/libvpx/vpx_util/vpx_thread.h rename to third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h diff --git a/third_party/libvpx/vpx_util/vpx_timestamp.h b/third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h similarity index 100% rename from third_party/libvpx/vpx_util/vpx_timestamp.h rename to third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h diff --git a/third_party/libvpx/vpx_util/vpx_util.mk b/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk similarity index 100% rename from third_party/libvpx/vpx_util/vpx_util.mk rename to third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk diff --git a/third_party/libvpx/vpx_util/vpx_write_yuv_frame.c b/third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c similarity index 100% rename from third_party/libvpx/vpx_util/vpx_write_yuv_frame.c rename to third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c diff --git a/third_party/libvpx/vpx_util/vpx_write_yuv_frame.h b/third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h similarity index 100% rename from third_party/libvpx/vpx_util/vpx_write_yuv_frame.h rename to third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h diff --git a/third_party/libvpx/vpxdec.c b/third_party/libvpx/source/libvpx/vpxdec.c similarity index 100% rename from third_party/libvpx/vpxdec.c rename to third_party/libvpx/source/libvpx/vpxdec.c diff --git a/third_party/libvpx/vpxenc.c b/third_party/libvpx/source/libvpx/vpxenc.c similarity index 91% rename from third_party/libvpx/vpxenc.c rename to third_party/libvpx/source/libvpx/vpxenc.c index 64288e83d280..a0122ef8048e 100644 --- a/third_party/libvpx/vpxenc.c +++ b/third_party/libvpx/source/libvpx/vpxenc.c @@ -114,10 +114,6 @@ static const arg_def_t pass_arg = ARG_DEF(NULL, "pass", 1, "Pass to execute (1/2)"); static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1, "First pass statistics file name"); -#if CONFIG_FP_MB_STATS -static const arg_def_t fpmbf_name = - ARG_DEF(NULL, "fpmbf", 1, "First pass block statistics file name"); -#endif static const arg_def_t limit = ARG_DEF(NULL, "limit", 1, "Stop encoding after n input frames"); static const arg_def_t skip = @@ -287,6 +283,64 @@ static const arg_def_t *rc_args[] = { &buf_sz, &buf_initial_sz, &buf_optimal_sz, NULL }; +#if CONFIG_VP9_ENCODER +static const arg_def_t use_vizier_rc_params = + ARG_DEF(NULL, "use-vizier-rc-params", 1, "Use vizier rc params"); +static const arg_def_t active_wq_factor = + ARG_DEF(NULL, "active-wq-factor", 1, "Active worst quality factor"); +static const arg_def_t err_per_mb_factor = + ARG_DEF(NULL, "err-per-mb-factor", 1, "Error per macroblock factor"); +static const arg_def_t sr_default_decay_limit = ARG_DEF( + NULL, "sr-default-decay-limit", 1, "Second reference default decay limit"); +static const arg_def_t sr_diff_factor = + ARG_DEF(NULL, "sr-diff-factor", 1, "Second reference diff factor"); +static const arg_def_t kf_err_per_mb_factor = ARG_DEF( + NULL, "kf-err-per-mb-factor", 1, "Keyframe error per macroblock factor"); +static const arg_def_t kf_frame_min_boost_factor = + ARG_DEF(NULL, "kf-frame-min-boost-factor", 1, "Keyframe min boost"); +static const arg_def_t kf_frame_max_boost_first_factor = + ARG_DEF(NULL, "kf-frame-max-boost-first-factor", 1, + "Max keyframe boost adjustment factor for first frame"); +static const arg_def_t kf_frame_max_boost_subs_factor = + ARG_DEF(NULL, "kf-frame-max-boost-subs-factor", 1, + "Max boost adjustment factor for subsequent KFs"); +static const arg_def_t kf_max_total_boost_factor = ARG_DEF( + NULL, "kf-max-total-boost-factor", 1, "Keyframe max total boost factor"); +static const arg_def_t gf_max_total_boost_factor = + ARG_DEF(NULL, "gf-max-total-boost-factor", 1, + "Golden frame max total boost factor"); +static const arg_def_t gf_frame_max_boost_factor = + ARG_DEF(NULL, "gf-frame-max-boost-factor", 1, + "Golden frame max per frame boost factor"); +static const arg_def_t zm_factor = + ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor"); +static const arg_def_t rd_mult_inter_qp_fac = + ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, + "RD multiplier adjustment for inter frames"); +static const arg_def_t rd_mult_arf_qp_fac = + ARG_DEF(NULL, "rd-mult-arf-qp-fac", 1, + "RD multiplier adjustment for alt-ref frames"); +static const arg_def_t rd_mult_key_qp_fac = ARG_DEF( + NULL, "rd-mult-key-qp-fac", 1, "RD multiplier adjustment for key frames"); +static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params, + &active_wq_factor, + &err_per_mb_factor, + &sr_default_decay_limit, + &sr_diff_factor, + &kf_err_per_mb_factor, + &kf_frame_min_boost_factor, + &kf_frame_max_boost_first_factor, + &kf_frame_max_boost_subs_factor, + &kf_max_total_boost_factor, + &gf_max_total_boost_factor, + &gf_frame_max_boost_factor, + &zm_factor, + &rd_mult_inter_qp_fac, + &rd_mult_arf_qp_fac, + &rd_mult_key_qp_fac, + NULL }; +#endif + static const arg_def_t bias_pct = ARG_DEF(NULL, "bias-pct", 1, "CBR/VBR bias (0=CBR, 100=VBR)"); static const arg_def_t minsection_pct = @@ -465,6 +519,13 @@ static const arg_def_t target_level = ARG_DEF( static const arg_def_t row_mt = ARG_DEF(NULL, "row-mt", 1, "Enable row based non-deterministic multi-threading in VP9"); + +static const arg_def_t disable_loopfilter = + ARG_DEF(NULL, "disable-loopfilter", 1, + "Control Loopfilter in VP9\n" + "0: Loopfilter on for all frames (default)\n" + "1: Loopfilter off for non reference frames\n" + "2: Loopfilter off for all frames"); #endif #if CONFIG_VP9_ENCODER @@ -495,6 +556,10 @@ static const arg_def_t *vp9_args[] = { &cpu_used_vp9, &max_gf_interval, &target_level, &row_mt, + &disable_loopfilter, +// NOTE: The entries above have a corresponding entry in vp9_arg_ctrl_map. The +// entries below do not have a corresponding entry in vp9_arg_ctrl_map. They +// must be listed at the end of vp9_args. #if CONFIG_VP9_HIGHBITDEPTH &bitdeptharg, &inbitdeptharg, @@ -527,6 +592,7 @@ static const int vp9_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP9E_SET_MAX_GF_INTERVAL, VP9E_SET_TARGET_LEVEL, VP9E_SET_ROW_MT, + VP9E_SET_DISABLE_LOOPFILTER, 0 }; #endif @@ -561,6 +627,8 @@ static void show_help(FILE *fout, int shorthelp) { #if CONFIG_VP9_ENCODER fprintf(fout, "\nVP9 Specific Options:\n"); arg_show_usage(fout, vp9_args); + fprintf(fout, "\nVizier Rate Control Options:\n"); + arg_show_usage(fout, vizier_rc_args); #endif fprintf(fout, "\nStream timebase (--timebase):\n" @@ -602,9 +670,6 @@ struct stream_config { struct vpx_codec_enc_cfg cfg; const char *out_fn; const char *stats_fn; -#if CONFIG_FP_MB_STATS - const char *fpmb_stats_fn; -#endif stereo_format_t stereo_fmt; int arg_ctrls[ARG_CTRL_CNT_MAX][2]; int arg_ctrl_cnt; @@ -632,9 +697,6 @@ struct stream_state { uint64_t cx_time; size_t nbytes; stats_io_t stats; -#if CONFIG_FP_MB_STATS - stats_io_t fpmb_stats; -#endif struct vpx_image *img; vpx_codec_ctx_t decoder; int mismatch_seen; @@ -871,10 +933,6 @@ static int parse_stream_params(struct VpxEncoderConfig *global, config->out_fn = arg.val; } else if (arg_match(&arg, &fpf_name, argi)) { config->stats_fn = arg.val; -#if CONFIG_FP_MB_STATS - } else if (arg_match(&arg, &fpmbf_name, argi)) { - config->fpmb_stats_fn = arg.val; -#endif } else if (arg_match(&arg, &use_webm, argi)) { #if CONFIG_WEBM_IO config->write_webm = 1; @@ -971,6 +1029,40 @@ static int parse_stream_params(struct VpxEncoderConfig *global, config->cfg.kf_max_dist = arg_parse_uint(&arg); } else if (arg_match(&arg, &kf_disabled, argi)) { config->cfg.kf_mode = VPX_KF_DISABLED; +#if CONFIG_VP9_ENCODER + } else if (arg_match(&arg, &use_vizier_rc_params, argi)) { + config->cfg.use_vizier_rc_params = arg_parse_int(&arg); + } else if (arg_match(&arg, &active_wq_factor, argi)) { + config->cfg.active_wq_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &err_per_mb_factor, argi)) { + config->cfg.err_per_mb_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &sr_default_decay_limit, argi)) { + config->cfg.sr_default_decay_limit = arg_parse_rational(&arg); + } else if (arg_match(&arg, &sr_diff_factor, argi)) { + config->cfg.sr_diff_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &kf_err_per_mb_factor, argi)) { + config->cfg.kf_err_per_mb_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &kf_frame_min_boost_factor, argi)) { + config->cfg.kf_frame_min_boost_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &kf_frame_max_boost_first_factor, argi)) { + config->cfg.kf_frame_max_boost_first_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &kf_frame_max_boost_subs_factor, argi)) { + config->cfg.kf_frame_max_boost_subs_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &kf_max_total_boost_factor, argi)) { + config->cfg.kf_max_total_boost_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &gf_max_total_boost_factor, argi)) { + config->cfg.gf_max_total_boost_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &gf_frame_max_boost_factor, argi)) { + config->cfg.gf_frame_max_boost_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &zm_factor, argi)) { + config->cfg.zm_factor = arg_parse_rational(&arg); + } else if (arg_match(&arg, &rd_mult_inter_qp_fac, argi)) { + config->cfg.rd_mult_inter_qp_fac = arg_parse_rational(&arg); + } else if (arg_match(&arg, &rd_mult_arf_qp_fac, argi)) { + config->cfg.rd_mult_arf_qp_fac = arg_parse_rational(&arg); + } else if (arg_match(&arg, &rd_mult_key_qp_fac, argi)) { + config->cfg.rd_mult_key_qp_fac = arg_parse_rational(&arg); +#endif #if CONFIG_VP9_HIGHBITDEPTH } else if (arg_match(&arg, &test16bitinternalarg, argi)) { if (strcmp(global->codec->name, "vp9") == 0) { @@ -1063,17 +1155,6 @@ static void validate_stream_config(const struct stream_state *stream, fatal("Stream %d: duplicate stats file (from stream %d)", streami->index, stream->index); } - -#if CONFIG_FP_MB_STATS - /* Check for two streams sharing a mb stats file. */ - if (streami != stream) { - const char *a = stream->config.fpmb_stats_fn; - const char *b = streami->config.fpmb_stats_fn; - if (a && b && !strcmp(a, b)) - fatal("Stream %d: duplicate mb stats file (from stream %d)", - streami->index, stream->index); - } -#endif } } @@ -1165,6 +1246,10 @@ static void show_stream_config(struct stream_state *stream, SHOW(kf_mode); SHOW(kf_min_dist); SHOW(kf_max_dist); + // Temporary use for debug + SHOW(use_vizier_rc_params); + SHOW(active_wq_factor.num); + SHOW(active_wq_factor.den); } static void open_output_file(struct stream_state *stream, @@ -1228,26 +1313,11 @@ static void setup_pass(struct stream_state *stream, fatal("Failed to open statistics store"); } -#if CONFIG_FP_MB_STATS - if (stream->config.fpmb_stats_fn) { - if (!stats_open_file(&stream->fpmb_stats, stream->config.fpmb_stats_fn, - pass)) - fatal("Failed to open mb statistics store"); - } else { - if (!stats_open_mem(&stream->fpmb_stats, pass)) - fatal("Failed to open mb statistics store"); - } -#endif - stream->config.cfg.g_pass = global->passes == 2 ? pass ? VPX_RC_LAST_PASS : VPX_RC_FIRST_PASS : VPX_RC_ONE_PASS; if (pass) { stream->config.cfg.rc_twopass_stats_in = stats_get(&stream->stats); -#if CONFIG_FP_MB_STATS - stream->config.cfg.rc_firstpass_mb_stats_in = - stats_get(&stream->fpmb_stats); -#endif } stream->cx_time = 0; @@ -1459,13 +1529,6 @@ static void get_cx_data(struct stream_state *stream, pkt->data.twopass_stats.sz); stream->nbytes += pkt->data.raw.sz; break; -#if CONFIG_FP_MB_STATS - case VPX_CODEC_FPMB_STATS_PKT: - stats_write(&stream->fpmb_stats, pkt->data.firstpass_mb_stats.buf, - pkt->data.firstpass_mb_stats.sz); - stream->nbytes += pkt->data.raw.sz; - break; -#endif case VPX_CODEC_PSNR_PKT: if (global->show_psnr) { @@ -1624,6 +1687,7 @@ int main(int argc, const char **argv_) { int res = 0; memset(&input, 0, sizeof(input)); + memset(&raw, 0, sizeof(raw)); exec_name = argv_[0]; /* Setup default input stream settings */ @@ -1769,14 +1833,10 @@ int main(int argc, const char **argv_) { FOREACH_STREAM(show_stream_config(stream, &global, &input)); if (pass == (global.pass ? global.pass - 1 : 0)) { - if (input.file_type == FILE_TYPE_Y4M) - /*The Y4M reader does its own allocation. - Just initialize this here to avoid problems if we never read any - frames.*/ - memset(&raw, 0, sizeof(raw)); - else + // The Y4M reader does its own allocation. + if (input.file_type != FILE_TYPE_Y4M) { vpx_img_alloc(&raw, input.fmt, input.width, input.height, 32); - + } FOREACH_STREAM(stream->rate_hist = init_rate_histogram( &stream->config.cfg, &global.framerate)); } @@ -1962,10 +2022,6 @@ int main(int argc, const char **argv_) { FOREACH_STREAM(stats_close(&stream->stats, global.passes - 1)); -#if CONFIG_FP_MB_STATS - FOREACH_STREAM(stats_close(&stream->fpmb_stats, global.passes - 1)); -#endif - if (global.pass) break; } diff --git a/third_party/libvpx/vpxenc.h b/third_party/libvpx/source/libvpx/vpxenc.h similarity index 100% rename from third_party/libvpx/vpxenc.h rename to third_party/libvpx/source/libvpx/vpxenc.h diff --git a/third_party/libvpx/vpxstats.c b/third_party/libvpx/source/libvpx/vpxstats.c similarity index 100% rename from third_party/libvpx/vpxstats.c rename to third_party/libvpx/source/libvpx/vpxstats.c diff --git a/third_party/libvpx/vpxstats.h b/third_party/libvpx/source/libvpx/vpxstats.h similarity index 100% rename from third_party/libvpx/vpxstats.h rename to third_party/libvpx/source/libvpx/vpxstats.h diff --git a/third_party/libvpx/warnings.c b/third_party/libvpx/source/libvpx/warnings.c similarity index 100% rename from third_party/libvpx/warnings.c rename to third_party/libvpx/source/libvpx/warnings.c diff --git a/third_party/libvpx/warnings.h b/third_party/libvpx/source/libvpx/warnings.h similarity index 100% rename from third_party/libvpx/warnings.h rename to third_party/libvpx/source/libvpx/warnings.h diff --git a/third_party/libvpx/webmdec.cc b/third_party/libvpx/source/libvpx/webmdec.cc similarity index 100% rename from third_party/libvpx/webmdec.cc rename to third_party/libvpx/source/libvpx/webmdec.cc diff --git a/third_party/libvpx/webmdec.h b/third_party/libvpx/source/libvpx/webmdec.h similarity index 100% rename from third_party/libvpx/webmdec.h rename to third_party/libvpx/source/libvpx/webmdec.h diff --git a/third_party/libvpx/webmenc.cc b/third_party/libvpx/source/libvpx/webmenc.cc similarity index 100% rename from third_party/libvpx/webmenc.cc rename to third_party/libvpx/source/libvpx/webmenc.cc diff --git a/third_party/libvpx/webmenc.h b/third_party/libvpx/source/libvpx/webmenc.h similarity index 100% rename from third_party/libvpx/webmenc.h rename to third_party/libvpx/source/libvpx/webmenc.h diff --git a/third_party/libvpx/y4menc.c b/third_party/libvpx/source/libvpx/y4menc.c similarity index 100% rename from third_party/libvpx/y4menc.c rename to third_party/libvpx/source/libvpx/y4menc.c diff --git a/third_party/libvpx/y4menc.h b/third_party/libvpx/source/libvpx/y4menc.h similarity index 100% rename from third_party/libvpx/y4menc.h rename to third_party/libvpx/source/libvpx/y4menc.h diff --git a/third_party/libvpx/y4minput.c b/third_party/libvpx/source/libvpx/y4minput.c similarity index 73% rename from third_party/libvpx/y4minput.c rename to third_party/libvpx/source/libvpx/y4minput.c index 007bd9971b4f..9a4bdbd7b539 100644 --- a/third_party/libvpx/y4minput.c +++ b/third_party/libvpx/source/libvpx/y4minput.c @@ -10,6 +10,7 @@ * Based on code from the OggTheora software codec source code, * Copyright (C) 2002-2010 The Xiph.Org Foundation and contributors. */ +#include #include #include #include @@ -51,15 +52,8 @@ static int file_read(void *buf, size_t size, FILE *file) { } static int y4m_parse_tags(y4m_input *_y4m, char *_tags) { - int got_w; - int got_h; - int got_fps; - int got_interlace; - int got_par; - int got_chroma; char *p; char *q; - got_w = got_h = got_fps = got_interlace = got_par = got_chroma = 0; for (p = _tags;; p = q) { /*Skip any leading spaces.*/ while (*p == ' ') p++; @@ -72,52 +66,119 @@ static int y4m_parse_tags(y4m_input *_y4m, char *_tags) { switch (p[0]) { case 'W': { if (sscanf(p + 1, "%d", &_y4m->pic_w) != 1) return -1; - got_w = 1; break; } case 'H': { if (sscanf(p + 1, "%d", &_y4m->pic_h) != 1) return -1; - got_h = 1; break; } case 'F': { if (sscanf(p + 1, "%d:%d", &_y4m->fps_n, &_y4m->fps_d) != 2) { return -1; } - got_fps = 1; break; } case 'I': { _y4m->interlace = p[1]; - got_interlace = 1; break; } case 'A': { if (sscanf(p + 1, "%d:%d", &_y4m->par_n, &_y4m->par_d) != 2) { return -1; } - got_par = 1; break; } case 'C': { if (q - p > 16) return -1; memcpy(_y4m->chroma_type, p + 1, q - p - 1); _y4m->chroma_type[q - p - 1] = '\0'; - got_chroma = 1; break; } /*Ignore unknown tags.*/ } } - if (!got_w || !got_h || !got_fps) return -1; - if (!got_interlace) _y4m->interlace = '?'; - if (!got_par) _y4m->par_n = _y4m->par_d = 0; - /*Chroma-type is not specified in older files, e.g., those generated by - mplayer.*/ - if (!got_chroma) strcpy(_y4m->chroma_type, "420"); return 0; } +// Copy a single tag into the buffer, along with a null character. +// Returns 0 if any file IO errors occur. +static int copy_tag(char *buf, size_t buf_len, char *end_tag, FILE *file) { + size_t i; + assert(buf_len >= 1); + // Skip leading space characters. + do { + if (!file_read(buf, 1, file)) { + return 0; + } + } while (buf[0] == ' '); + + // If we hit the newline, treat this as the "empty" tag. + if (buf[0] == '\n') { + buf[0] = '\0'; + *end_tag = '\n'; + return 1; + } + + // Copy over characters until a space is hit, or the buffer is exhausted. + for (i = 1; i < buf_len; ++i) { + if (!file_read(buf + i, 1, file)) { + return 0; + } + if (buf[i] == ' ' || buf[i] == '\n') { + break; + } + } + if (i == buf_len) { + fprintf(stderr, "Error: Y4M header tags must be less than %lu characters\n", + (unsigned long)i); + return 0; + } + *end_tag = buf[i]; + buf[i] = '\0'; + return 1; +} + +/* Returns 1 if tags were parsed successfully, 0 otherwise. */ +static int parse_tags(y4m_input *y4m_ctx, FILE *file) { + char tag[256]; + char end; /* Character denoting the end of the tag, ' ' or '\n'. */ + /* Set Y4M tags to defaults, updating them as processing occurs. Mandatory + fields are marked with -1 and will be checked after the tags are parsed. */ + y4m_ctx->pic_w = -1; + y4m_ctx->pic_h = -1; + y4m_ctx->fps_n = -1; /* Also serves as marker for fps_d */ + y4m_ctx->par_n = 0; + y4m_ctx->par_d = 0; + y4m_ctx->interlace = '?'; + snprintf(y4m_ctx->chroma_type, sizeof(y4m_ctx->chroma_type), "420"); + + /* Find one tag at a time. */ + do { + if (!copy_tag(tag, sizeof(tag), &end, file)) { + return 0; + } + /* y4m_parse_tags returns 0 on success. */ + if (y4m_parse_tags(y4m_ctx, tag)) { + return 0; + } + } while (end != '\n'); + + /* Check the mandatory fields. */ + if (y4m_ctx->pic_w == -1) { + fprintf(stderr, "Width field missing\n"); + return 0; + } + if (y4m_ctx->pic_h == -1) { + fprintf(stderr, "Height field missing\n"); + return 0; + } + if (y4m_ctx->fps_n == -1) { + fprintf(stderr, "FPS field missing\n"); + return 0; + } + return 1; +} + /*All anti-aliasing filters in the following conversion functions are based on one of two window functions: The 6-tap Lanczos window (for down-sampling and shifts): @@ -224,26 +285,6 @@ static void y4m_42xmpeg2_42xjpeg_helper(unsigned char *_dst, } } -/*Handles both 422 and 420mpeg2 to 422jpeg and 420jpeg, respectively.*/ -static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m, unsigned char *_dst, - unsigned char *_aux) { - int c_w; - int c_h; - int c_sz; - int pli; - /*Skip past the luma data.*/ - _dst += _y4m->pic_w * _y4m->pic_h; - /*Compute the size of each chroma plane.*/ - c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h; - c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v; - c_sz = c_w * c_h; - for (pli = 1; pli < 3; pli++) { - y4m_42xmpeg2_42xjpeg_helper(_dst, _aux, c_w, c_h); - _dst += c_sz; - _aux += c_sz; - } -} - /*This format is only used for interlaced content, but is included for completeness. @@ -784,277 +825,271 @@ static void y4m_convert_null(y4m_input *_y4m, unsigned char *_dst, (void)_aux; } -int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip, - int only_420) { - char buffer[80] = { 0 }; - int ret; - int i; - /*Read until newline, or 80 cols, whichever happens first.*/ - for (i = 0; i < 79; i++) { - if (_nskip > 0) { - buffer[i] = *_skip++; - _nskip--; - } else { - if (!file_read(buffer + i, 1, _fin)) return -1; - } - if (buffer[i] == '\n') break; +static const char TAG[] = "YUV4MPEG2"; + +int y4m_input_open(y4m_input *y4m_ctx, FILE *file, char *skip_buffer, + int num_skip, int only_420) { + // File must start with |TAG|. + char tag_buffer[9]; // 9 == strlen(TAG) + // Read as much as possible from |skip_buffer|, which were characters + // that were previously read from the file to do input-type detection. + assert(num_skip >= 0 && num_skip <= 8); + if (num_skip > 0) { + memcpy(tag_buffer, skip_buffer, num_skip); } - /*We skipped too much header data.*/ - if (_nskip > 0) return -1; - if (i == 79) { - fprintf(stderr, "Error parsing header; not a YUV2MPEG2 file?\n"); + // Start reading from the file now that the |skip_buffer| is depleted. + if (!file_read(tag_buffer + num_skip, 9 - num_skip, file)) { return -1; } - buffer[i] = '\0'; - if (memcmp(buffer, "YUV4MPEG", 8)) { - fprintf(stderr, "Incomplete magic for YUV4MPEG file.\n"); + if (memcmp(TAG, tag_buffer, 9) != 0) { + fprintf(stderr, "Error parsing header: must start with %s\n", TAG); return -1; } - if (buffer[8] != '2') { - fprintf(stderr, "Incorrect YUV input file version; YUV4MPEG2 required.\n"); + // Next character must be a space. + if (!file_read(tag_buffer, 1, file) || tag_buffer[0] != ' ') { + fprintf(stderr, "Error parsing header: space must follow %s\n", TAG); + return -1; } - ret = y4m_parse_tags(_y4m, buffer + 5); - if (ret < 0) { - fprintf(stderr, "Error parsing YUV4MPEG2 header.\n"); - return ret; + if (!parse_tags(y4m_ctx, file)) { + fprintf(stderr, "Error parsing %s header.\n", TAG); } - if (_y4m->interlace == '?') { + if (y4m_ctx->interlace == '?') { fprintf(stderr, "Warning: Input video interlacing format unknown; " "assuming progressive scan.\n"); - } else if (_y4m->interlace != 'p') { + } else if (y4m_ctx->interlace != 'p') { fprintf(stderr, "Input video is interlaced; " "Only progressive scan handled.\n"); return -1; } - _y4m->vpx_fmt = VPX_IMG_FMT_I420; - _y4m->bps = 12; - _y4m->bit_depth = 8; - if (strcmp(_y4m->chroma_type, "420") == 0 || - strcmp(_y4m->chroma_type, "420jpeg") == 0) { - _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = - _y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2); + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I420; + y4m_ctx->bps = 12; + y4m_ctx->bit_depth = 8; + y4m_ctx->aux_buf = NULL; + y4m_ctx->dst_buf = NULL; + if (strcmp(y4m_ctx->chroma_type, "420") == 0 || + strcmp(y4m_ctx->chroma_type, "420jpeg") == 0 || + strcmp(y4m_ctx->chroma_type, "420mpeg2") == 0) { + y4m_ctx->src_c_dec_h = y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_v = + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = + y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * ((y4m_ctx->pic_h + 1) / 2); /* Natively supported: no conversion required. */ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; - } else if (strcmp(_y4m->chroma_type, "420p10") == 0) { - _y4m->src_c_dec_h = 2; - _y4m->dst_c_dec_h = 2; - _y4m->src_c_dec_v = 2; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = - 2 * (_y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2)); + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; + } else if (strcmp(y4m_ctx->chroma_type, "420p10") == 0) { + y4m_ctx->src_c_dec_h = 2; + y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 2; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = + 2 * (y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * ((y4m_ctx->pic_h + 1) / 2)); /* Natively supported: no conversion required. */ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; - _y4m->bit_depth = 10; - _y4m->bps = 15; - _y4m->vpx_fmt = VPX_IMG_FMT_I42016; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; + y4m_ctx->bit_depth = 10; + y4m_ctx->bps = 15; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I42016; if (only_420) { fprintf(stderr, "Unsupported conversion from 420p10 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "420p12") == 0) { - _y4m->src_c_dec_h = 2; - _y4m->dst_c_dec_h = 2; - _y4m->src_c_dec_v = 2; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = - 2 * (_y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2)); + } else if (strcmp(y4m_ctx->chroma_type, "420p12") == 0) { + y4m_ctx->src_c_dec_h = 2; + y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 2; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = + 2 * (y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * ((y4m_ctx->pic_h + 1) / 2)); /* Natively supported: no conversion required. */ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; - _y4m->bit_depth = 12; - _y4m->bps = 18; - _y4m->vpx_fmt = VPX_IMG_FMT_I42016; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; + y4m_ctx->bit_depth = 12; + y4m_ctx->bps = 18; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I42016; if (only_420) { fprintf(stderr, "Unsupported conversion from 420p12 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "420mpeg2") == 0) { - _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; - /*Chroma filter required: read into the aux buf first.*/ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = - 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2); - _y4m->convert = y4m_convert_42xmpeg2_42xjpeg; - } else if (strcmp(_y4m->chroma_type, "420paldv") == 0) { - _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + } else if (strcmp(y4m_ctx->chroma_type, "420paldv") == 0) { + y4m_ctx->src_c_dec_h = y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_v = + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*Chroma filter required: read into the aux buf first. We need to make two filter passes, so we need some extra space in the aux buffer.*/ - _y4m->aux_buf_sz = 3 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2); - _y4m->aux_buf_read_sz = - 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2); - _y4m->convert = y4m_convert_42xpaldv_42xjpeg; - } else if (strcmp(_y4m->chroma_type, "422jpeg") == 0) { - _y4m->src_c_dec_h = _y4m->dst_c_dec_h = 2; - _y4m->src_c_dec_v = 1; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + y4m_ctx->aux_buf_sz = + 3 * ((y4m_ctx->pic_w + 1) / 2) * ((y4m_ctx->pic_h + 1) / 2); + y4m_ctx->aux_buf_read_sz = + 2 * ((y4m_ctx->pic_w + 1) / 2) * ((y4m_ctx->pic_h + 1) / 2); + y4m_ctx->convert = y4m_convert_42xpaldv_42xjpeg; + } else if (strcmp(y4m_ctx->chroma_type, "422jpeg") == 0) { + y4m_ctx->src_c_dec_h = y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*Chroma filter required: read into the aux buf first.*/ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = - 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; - _y4m->convert = y4m_convert_422jpeg_420jpeg; - } else if (strcmp(_y4m->chroma_type, "422") == 0) { - _y4m->src_c_dec_h = 2; - _y4m->src_c_dec_v = 1; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = + 2 * ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; + y4m_ctx->convert = y4m_convert_422jpeg_420jpeg; + } else if (strcmp(y4m_ctx->chroma_type, "422") == 0) { + y4m_ctx->src_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 1; if (only_420) { - _y4m->dst_c_dec_h = 2; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*Chroma filter required: read into the aux buf first. We need to make two filter passes, so we need some extra space in the aux buffer.*/ - _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; - _y4m->aux_buf_sz = - _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; - _y4m->convert = y4m_convert_422_420jpeg; + y4m_ctx->aux_buf_read_sz = + 2 * ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz + + ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; + y4m_ctx->convert = y4m_convert_422_420jpeg; } else { - _y4m->vpx_fmt = VPX_IMG_FMT_I422; - _y4m->bps = 16; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = - _y4m->pic_w * _y4m->pic_h + 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I422; + y4m_ctx->bps = 16; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = + y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; /*Natively supported: no conversion required.*/ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; } - } else if (strcmp(_y4m->chroma_type, "422p10") == 0) { - _y4m->src_c_dec_h = 2; - _y4m->src_c_dec_v = 1; - _y4m->vpx_fmt = VPX_IMG_FMT_I42216; - _y4m->bps = 20; - _y4m->bit_depth = 10; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = 2 * (_y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h); - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + } else if (strcmp(y4m_ctx->chroma_type, "422p10") == 0) { + y4m_ctx->src_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I42216; + y4m_ctx->bps = 20; + y4m_ctx->bit_depth = 10; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = + 2 * (y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h); + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; if (only_420) { fprintf(stderr, "Unsupported conversion from 422p10 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "422p12") == 0) { - _y4m->src_c_dec_h = 2; - _y4m->src_c_dec_v = 1; - _y4m->vpx_fmt = VPX_IMG_FMT_I42216; - _y4m->bps = 24; - _y4m->bit_depth = 12; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = 2 * (_y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h); - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + } else if (strcmp(y4m_ctx->chroma_type, "422p12") == 0) { + y4m_ctx->src_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I42216; + y4m_ctx->bps = 24; + y4m_ctx->bit_depth = 12; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = + 2 * (y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h); + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; if (only_420) { fprintf(stderr, "Unsupported conversion from 422p12 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "411") == 0) { - _y4m->src_c_dec_h = 4; - _y4m->dst_c_dec_h = 2; - _y4m->src_c_dec_v = 1; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + } else if (strcmp(y4m_ctx->chroma_type, "411") == 0) { + y4m_ctx->src_c_dec_h = 4; + y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*Chroma filter required: read into the aux buf first. We need to make two filter passes, so we need some extra space in the aux buffer.*/ - _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 3) / 4) * _y4m->pic_h; - _y4m->aux_buf_sz = - _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; - _y4m->convert = y4m_convert_411_420jpeg; + y4m_ctx->aux_buf_read_sz = 2 * ((y4m_ctx->pic_w + 3) / 4) * y4m_ctx->pic_h; + y4m_ctx->aux_buf_sz = + y4m_ctx->aux_buf_read_sz + ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; + y4m_ctx->convert = y4m_convert_411_420jpeg; fprintf(stderr, "Unsupported conversion from yuv 411\n"); return -1; - } else if (strcmp(_y4m->chroma_type, "444") == 0) { - _y4m->src_c_dec_h = 1; - _y4m->src_c_dec_v = 1; + } else if (strcmp(y4m_ctx->chroma_type, "444") == 0) { + y4m_ctx->src_c_dec_h = 1; + y4m_ctx->src_c_dec_v = 1; if (only_420) { - _y4m->dst_c_dec_h = 2; - _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + y4m_ctx->dst_c_dec_h = 2; + y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*Chroma filter required: read into the aux buf first. We need to make two filter passes, so we need some extra space in the aux buffer.*/ - _y4m->aux_buf_read_sz = 2 * _y4m->pic_w * _y4m->pic_h; - _y4m->aux_buf_sz = - _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h; - _y4m->convert = y4m_convert_444_420jpeg; + y4m_ctx->aux_buf_read_sz = 2 * y4m_ctx->pic_w * y4m_ctx->pic_h; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz + + ((y4m_ctx->pic_w + 1) / 2) * y4m_ctx->pic_h; + y4m_ctx->convert = y4m_convert_444_420jpeg; } else { - _y4m->vpx_fmt = VPX_IMG_FMT_I444; - _y4m->bps = 24; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = 3 * _y4m->pic_w * _y4m->pic_h; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I444; + y4m_ctx->bps = 24; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = 3 * y4m_ctx->pic_w * y4m_ctx->pic_h; /*Natively supported: no conversion required.*/ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; } - } else if (strcmp(_y4m->chroma_type, "444p10") == 0) { - _y4m->src_c_dec_h = 1; - _y4m->src_c_dec_v = 1; - _y4m->vpx_fmt = VPX_IMG_FMT_I44416; - _y4m->bps = 30; - _y4m->bit_depth = 10; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = 2 * 3 * _y4m->pic_w * _y4m->pic_h; - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + } else if (strcmp(y4m_ctx->chroma_type, "444p10") == 0) { + y4m_ctx->src_c_dec_h = 1; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I44416; + y4m_ctx->bps = 30; + y4m_ctx->bit_depth = 10; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = 2 * 3 * y4m_ctx->pic_w * y4m_ctx->pic_h; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; if (only_420) { fprintf(stderr, "Unsupported conversion from 444p10 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "444p12") == 0) { - _y4m->src_c_dec_h = 1; - _y4m->src_c_dec_v = 1; - _y4m->vpx_fmt = VPX_IMG_FMT_I44416; - _y4m->bps = 36; - _y4m->bit_depth = 12; - _y4m->dst_c_dec_h = _y4m->src_c_dec_h; - _y4m->dst_c_dec_v = _y4m->src_c_dec_v; - _y4m->dst_buf_read_sz = 2 * 3 * _y4m->pic_w * _y4m->pic_h; - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_null; + } else if (strcmp(y4m_ctx->chroma_type, "444p12") == 0) { + y4m_ctx->src_c_dec_h = 1; + y4m_ctx->src_c_dec_v = 1; + y4m_ctx->vpx_fmt = VPX_IMG_FMT_I44416; + y4m_ctx->bps = 36; + y4m_ctx->bit_depth = 12; + y4m_ctx->dst_c_dec_h = y4m_ctx->src_c_dec_h; + y4m_ctx->dst_c_dec_v = y4m_ctx->src_c_dec_v; + y4m_ctx->dst_buf_read_sz = 2 * 3 * y4m_ctx->pic_w * y4m_ctx->pic_h; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_null; if (only_420) { fprintf(stderr, "Unsupported conversion from 444p12 to 420jpeg\n"); return -1; } - } else if (strcmp(_y4m->chroma_type, "mono") == 0) { - _y4m->src_c_dec_h = _y4m->src_c_dec_v = 0; - _y4m->dst_c_dec_h = _y4m->dst_c_dec_v = 2; - _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h; + } else if (strcmp(y4m_ctx->chroma_type, "mono") == 0) { + y4m_ctx->src_c_dec_h = y4m_ctx->src_c_dec_v = 0; + y4m_ctx->dst_c_dec_h = y4m_ctx->dst_c_dec_v = 2; + y4m_ctx->dst_buf_read_sz = y4m_ctx->pic_w * y4m_ctx->pic_h; /*No extra space required, but we need to clear the chroma planes.*/ - _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0; - _y4m->convert = y4m_convert_mono_420jpeg; + y4m_ctx->aux_buf_sz = y4m_ctx->aux_buf_read_sz = 0; + y4m_ctx->convert = y4m_convert_mono_420jpeg; } else { - fprintf(stderr, "Unknown chroma sampling type: %s\n", _y4m->chroma_type); + fprintf(stderr, "Unknown chroma sampling type: %s\n", y4m_ctx->chroma_type); return -1; } /*The size of the final frame buffers is always computed from the destination chroma decimation type.*/ - _y4m->dst_buf_sz = - _y4m->pic_w * _y4m->pic_h + - 2 * ((_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h) * - ((_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v); - if (_y4m->bit_depth == 8) - _y4m->dst_buf = (unsigned char *)malloc(_y4m->dst_buf_sz); + y4m_ctx->dst_buf_sz = + y4m_ctx->pic_w * y4m_ctx->pic_h + + 2 * ((y4m_ctx->pic_w + y4m_ctx->dst_c_dec_h - 1) / y4m_ctx->dst_c_dec_h) * + ((y4m_ctx->pic_h + y4m_ctx->dst_c_dec_v - 1) / y4m_ctx->dst_c_dec_v); + if (y4m_ctx->bit_depth == 8) + y4m_ctx->dst_buf = (unsigned char *)malloc(y4m_ctx->dst_buf_sz); else - _y4m->dst_buf = (unsigned char *)malloc(2 * _y4m->dst_buf_sz); + y4m_ctx->dst_buf = (unsigned char *)malloc(2 * y4m_ctx->dst_buf_sz); - if (_y4m->aux_buf_sz > 0) - _y4m->aux_buf = (unsigned char *)malloc(_y4m->aux_buf_sz); + if (y4m_ctx->aux_buf_sz > 0) + y4m_ctx->aux_buf = (unsigned char *)malloc(y4m_ctx->aux_buf_sz); return 0; } diff --git a/third_party/libvpx/y4minput.h b/third_party/libvpx/source/libvpx/y4minput.h similarity index 78% rename from third_party/libvpx/y4minput.h rename to third_party/libvpx/source/libvpx/y4minput.h index a4a8b18dc53d..573750d74996 100644 --- a/third_party/libvpx/y4minput.h +++ b/third_party/libvpx/source/libvpx/y4minput.h @@ -56,8 +56,16 @@ struct y4m_input { unsigned int bit_depth; }; -int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip, - int only_420); +/** + * Open the input file, treating it as Y4M. |y4m_ctx| is filled in after + * reading it. The |skip_buffer| indicates bytes that were previously read + * from |file|, to do input-type detection; this buffer will be read before + * the |file| is read. It is of size |num_skip|, which *must* be 8 or less. + * + * Returns 0 on success, -1 on failure. + */ +int y4m_input_open(y4m_input *y4m_ctx, FILE *file, char *skip_buffer, + int num_skip, int only_420); void y4m_input_close(y4m_input *_y4m); int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *img); diff --git a/third_party/libvpx/test/ratectrl_rtc_test.cc b/third_party/libvpx/test/ratectrl_rtc_test.cc deleted file mode 100644 index e044885e7c27..000000000000 --- a/third_party/libvpx/test/ratectrl_rtc_test.cc +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2020 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "vp9/ratectrl_rtc.h" - -#include // NOLINT -#include - -#include "./vpx_config.h" -#include "third_party/googletest/src/include/gtest/gtest.h" -#include "test/codec_factory.h" -#include "test/encode_test_driver.h" -#include "test/util.h" -#include "test/video_source.h" -#include "vpx/vpx_codec.h" -#include "vpx_ports/bitops.h" - -namespace { - -const size_t kNumFrame = 850; - -struct FrameInfo { - friend std::istream &operator>>(std::istream &is, FrameInfo &info) { - is >> info.frame_id >> info.spatial_id >> info.temporal_id >> info.base_q >> - info.target_bandwidth >> info.buffer_level >> info.filter_level_ >> - info.bytes_used; - return is; - } - int frame_id; - int spatial_id; - int temporal_id; - // Base QP - int base_q; - size_t target_bandwidth; - size_t buffer_level; - // Loopfilter level - int filter_level_; - // Frame size for current frame, used for pose encode update - size_t bytes_used; -}; - -// This test runs the rate control interface and compare against ground truth -// generated by encoders. -// Settings for the encoder: -// For 1 layer: -// -// examples/vpx_temporal_svc_encoder gipsrec_motion1.1280_720.yuv out vp9 -// 1280 720 1 30 7 0 0 1 0 1000 -// -// For SVC (3 temporal layers, 3 spatial layers): -// -// examples/vp9_spatial_svc_encoder -f 10000 -w 1280 -h 720 -t 1/30 -sl 3 -// -k 10000 -bl 100,140,200,250,350,500,450,630,900 -b 1600 --rc-end-usage=1 -// --lag-in-frames=0 --passes=1 --speed=7 --threads=1 -// --temporal-layering-mode=3 -aq 1 -rcstat 1 -// gipsrec_motion1.1280_720.yuv -o out.webm -// -// - AQ_Mode 0 -// - Disable golden refresh -// - Bitrate x 2 at frame/superframe 200 -// - Bitrate / 4 at frame/superframe 400 -// -// The generated file includes: -// frame number, spatial layer ID, temporal layer ID, base QP, target -// bandwidth, buffer level, loopfilter level, encoded frame size -// TODO(jianj): Remove golden files, and run actual encoding in this test. -class RcInterfaceTest : public ::testing::Test { - public: - explicit RcInterfaceTest() {} - - virtual ~RcInterfaceTest() {} - - protected: - void RunOneLayer() { - SetConfigOneLayer(); - rc_api_->Create(rc_cfg_); - FrameInfo frame_info; - libvpx::VP9FrameParamsQpRTC frame_params; - frame_params.frame_type = KEY_FRAME; - frame_params.spatial_layer_id = 0; - frame_params.temporal_layer_id = 0; - std::ifstream one_layer_file; - one_layer_file.open(libvpx_test::GetDataPath() + - "/rc_interface_test_one_layer"); - ASSERT_EQ(one_layer_file.rdstate() & std::ifstream::failbit, 0); - for (size_t i = 0; i < kNumFrame; i++) { - one_layer_file >> frame_info; - if (frame_info.frame_id > 0) frame_params.frame_type = INTER_FRAME; - if (frame_info.frame_id == 200) { - rc_cfg_.target_bandwidth = rc_cfg_.target_bandwidth * 2; - rc_api_->UpdateRateControl(rc_cfg_); - } else if (frame_info.frame_id == 400) { - rc_cfg_.target_bandwidth = rc_cfg_.target_bandwidth / 4; - rc_api_->UpdateRateControl(rc_cfg_); - } - ASSERT_EQ(frame_info.spatial_id, 0); - ASSERT_EQ(frame_info.temporal_id, 0); - rc_api_->ComputeQP(frame_params); - ASSERT_EQ(rc_api_->GetQP(), frame_info.base_q); - ASSERT_EQ(rc_api_->GetLoopfilterLevel(), frame_info.filter_level_); - rc_api_->PostEncodeUpdate(frame_info.bytes_used); - } - } - - void RunSVC() { - SetConfigSVC(); - rc_api_->Create(rc_cfg_); - FrameInfo frame_info; - libvpx::VP9FrameParamsQpRTC frame_params; - frame_params.frame_type = KEY_FRAME; - std::ifstream svc_file; - svc_file.open(std::string(std::getenv("LIBVPX_TEST_DATA_PATH")) + - "/rc_interface_test_svc"); - ASSERT_EQ(svc_file.rdstate() & std::ifstream::failbit, 0); - for (size_t i = 0; i < kNumFrame * rc_cfg_.ss_number_layers; i++) { - svc_file >> frame_info; - if (frame_info.frame_id > 0) frame_params.frame_type = INTER_FRAME; - if (frame_info.frame_id == 200 * rc_cfg_.ss_number_layers) { - for (int layer = 0; - layer < rc_cfg_.ss_number_layers * rc_cfg_.ts_number_layers; - layer++) - rc_cfg_.layer_target_bitrate[layer] *= 2; - rc_cfg_.target_bandwidth *= 2; - rc_api_->UpdateRateControl(rc_cfg_); - } else if (frame_info.frame_id == 400 * rc_cfg_.ss_number_layers) { - for (int layer = 0; - layer < rc_cfg_.ss_number_layers * rc_cfg_.ts_number_layers; - layer++) - rc_cfg_.layer_target_bitrate[layer] /= 4; - rc_cfg_.target_bandwidth /= 4; - rc_api_->UpdateRateControl(rc_cfg_); - } - frame_params.spatial_layer_id = frame_info.spatial_id; - frame_params.temporal_layer_id = frame_info.temporal_id; - rc_api_->ComputeQP(frame_params); - ASSERT_EQ(rc_api_->GetQP(), frame_info.base_q); - ASSERT_EQ(rc_api_->GetLoopfilterLevel(), frame_info.filter_level_); - rc_api_->PostEncodeUpdate(frame_info.bytes_used); - } - } - - private: - void SetConfigOneLayer() { - rc_cfg_.width = 1280; - rc_cfg_.height = 720; - rc_cfg_.max_quantizer = 52; - rc_cfg_.min_quantizer = 2; - rc_cfg_.target_bandwidth = 1000; - rc_cfg_.buf_initial_sz = 600; - rc_cfg_.buf_optimal_sz = 600; - rc_cfg_.buf_sz = 1000; - rc_cfg_.undershoot_pct = 50; - rc_cfg_.overshoot_pct = 50; - rc_cfg_.max_intra_bitrate_pct = 1000; - rc_cfg_.framerate = 30.0; - rc_cfg_.ss_number_layers = 1; - rc_cfg_.ts_number_layers = 1; - rc_cfg_.scaling_factor_num[0] = 1; - rc_cfg_.scaling_factor_den[0] = 1; - rc_cfg_.layer_target_bitrate[0] = 1000; - rc_cfg_.max_quantizers[0] = 52; - rc_cfg_.min_quantizers[0] = 2; - } - - void SetConfigSVC() { - rc_cfg_.width = 1280; - rc_cfg_.height = 720; - rc_cfg_.max_quantizer = 56; - rc_cfg_.min_quantizer = 2; - rc_cfg_.target_bandwidth = 1600; - rc_cfg_.buf_initial_sz = 500; - rc_cfg_.buf_optimal_sz = 600; - rc_cfg_.buf_sz = 1000; - rc_cfg_.undershoot_pct = 50; - rc_cfg_.overshoot_pct = 50; - rc_cfg_.max_intra_bitrate_pct = 900; - rc_cfg_.framerate = 30.0; - rc_cfg_.ss_number_layers = 3; - rc_cfg_.ts_number_layers = 3; - - rc_cfg_.scaling_factor_num[0] = 1; - rc_cfg_.scaling_factor_den[0] = 4; - rc_cfg_.scaling_factor_num[1] = 2; - rc_cfg_.scaling_factor_den[1] = 4; - rc_cfg_.scaling_factor_num[2] = 4; - rc_cfg_.scaling_factor_den[2] = 4; - - rc_cfg_.ts_rate_decimator[0] = 4; - rc_cfg_.ts_rate_decimator[1] = 2; - rc_cfg_.ts_rate_decimator[2] = 1; - - rc_cfg_.layer_target_bitrate[0] = 100; - rc_cfg_.layer_target_bitrate[1] = 140; - rc_cfg_.layer_target_bitrate[2] = 200; - rc_cfg_.layer_target_bitrate[3] = 250; - rc_cfg_.layer_target_bitrate[4] = 350; - rc_cfg_.layer_target_bitrate[5] = 500; - rc_cfg_.layer_target_bitrate[6] = 450; - rc_cfg_.layer_target_bitrate[7] = 630; - rc_cfg_.layer_target_bitrate[8] = 900; - - for (int sl = 0; sl < rc_cfg_.ss_number_layers; ++sl) { - for (int tl = 0; tl < rc_cfg_.ts_number_layers; ++tl) { - const int i = sl * rc_cfg_.ts_number_layers + tl; - rc_cfg_.max_quantizers[i] = 56; - rc_cfg_.min_quantizers[i] = 2; - } - } - } - - std::unique_ptr rc_api_; - libvpx::VP9RateControlRtcConfig rc_cfg_; -}; - -TEST_F(RcInterfaceTest, OneLayer) { RunOneLayer(); } - -TEST_F(RcInterfaceTest, SVC) { RunSVC(); } -} // namespace - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/third_party/libvpx/vpx_dsp/arm/sum_neon.h b/third_party/libvpx/vpx_dsp/arm/sum_neon.h deleted file mode 100644 index 9e6833aad3d8..000000000000 --- a/third_party/libvpx/vpx_dsp/arm/sum_neon.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef VPX_VPX_DSP_ARM_SUM_NEON_H_ -#define VPX_VPX_DSP_ARM_SUM_NEON_H_ - -#include - -#include "./vpx_config.h" -#include "vpx/vpx_integer.h" - -static INLINE int32x2_t horizontal_add_int16x8(const int16x8_t a) { - const int32x4_t b = vpaddlq_s16(a); - const int64x2_t c = vpaddlq_s32(b); - return vadd_s32(vreinterpret_s32_s64(vget_low_s64(c)), - vreinterpret_s32_s64(vget_high_s64(c))); -} - -static INLINE uint32x2_t horizontal_add_uint16x8(const uint16x8_t a) { - const uint32x4_t b = vpaddlq_u16(a); - const uint64x2_t c = vpaddlq_u32(b); - return vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)), - vreinterpret_u32_u64(vget_high_u64(c))); -} - -static INLINE uint32x2_t horizontal_add_uint32x4(const uint32x4_t a) { - const uint64x2_t b = vpaddlq_u32(a); - return vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)), - vreinterpret_u32_u64(vget_high_u64(b))); -} -#endif // VPX_VPX_DSP_ARM_SUM_NEON_H_