summaryrefslogtreecommitdiff
path: root/chromium/third_party/libvpx
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 10:22:43 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 12:36:28 +0000
commit271a6c3487a14599023a9106329505597638d793 (patch)
treee040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/third_party/libvpx
parent7b2ffa587235a47d4094787d72f38102089f402a (diff)
downloadqtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/libvpx')
-rw-r--r--chromium/third_party/libvpx/OWNERS1
-rw-r--r--chromium/third_party/libvpx/README.chromium4
-rw-r--r--chromium/third_party/libvpx/libvpx_srcs.gni99
-rw-r--r--chromium/third_party/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/config/nacl/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/vpx_version.h8
-rw-r--r--chromium/third_party/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h7
-rw-r--r--chromium/third_party/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/config/win/x64/vpx_dsp_rtcd.h19
-rw-r--r--chromium/third_party/libvpx/source/libvpx/.mailmap2
-rw-r--r--chromium/third_party/libvpx/source/libvpx/AUTHORS8
-rw-r--r--chromium/third_party/libvpx/source/libvpx/CHANGELOG18
-rw-r--r--chromium/third_party/libvpx/source/libvpx/README2
-rw-r--r--chromium/third_party/libvpx/source/libvpx/build/make/configure.sh5
-rwxr-xr-xchromium/third_party/libvpx/source/libvpx/configure14
-rw-r--r--chromium/third_party/libvpx/source/libvpx/examples.mk2
-rw-r--r--chromium/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc74
-rw-r--r--chromium/third_party/libvpx/source/libvpx/libs.mk3
-rw-r--r--chromium/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx2
-rw-r--r--chromium/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc9
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py132
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py36
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py205
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py117
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py37
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py76
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde163
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde138
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde102
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde138
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde61
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde59
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde82
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde28
-rw-r--r--chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde74
-rw-r--r--chromium/third_party/libvpx/source/libvpx/video_writer.c14
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h3
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c73
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h8
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c28
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h8
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c236
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c175
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h4
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c107
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h1
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c597
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h35
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c54
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c73
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h6
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c24
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h9
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c48
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h4
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c27
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h4
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c77
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vp9/vp9cx.mk8
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx/exports_spatial_svc5
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c21
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h8
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c18
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/sad.c1
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/variance.h1
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk10
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h4
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl24
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c65
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h45
-rw-r--r--chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk1
85 files changed, 3003 insertions, 727 deletions
diff --git a/chromium/third_party/libvpx/OWNERS b/chromium/third_party/libvpx/OWNERS
index 652467862c7..94c24159cc2 100644
--- a/chromium/third_party/libvpx/OWNERS
+++ b/chromium/third_party/libvpx/OWNERS
@@ -2,3 +2,4 @@ tomfinegan@chromium.org
johannkoenig@google.com
jzern@chromium.org
jzern@google.com
+# COMPONENT: Internals>Media>Video
diff --git a/chromium/third_party/libvpx/README.chromium b/chromium/third_party/libvpx/README.chromium
index ffbe5336b9c..2cf027d7705 100644
--- a/chromium/third_party/libvpx/README.chromium
+++ b/chromium/third_party/libvpx/README.chromium
@@ -5,9 +5,9 @@ License: BSD
License File: source/libvpx/LICENSE
Security Critical: yes
-Date: Tuesday May 28 2019
+Date: Tuesday July 23 2019
Branch: master
-Commit: 0308a9a132612006056f9920c069a1942e49c26c
+Commit: 18d309c12734d2f06d54ad1716e512153a13ab9d
Description:
Contains the sources used to compile libvpx binaries used by Google Chrome and
diff --git a/chromium/third_party/libvpx/libvpx_srcs.gni b/chromium/third_party/libvpx/libvpx_srcs.gni
index 52b42ef1422..bbe73b89ea7 100644
--- a/chromium/third_party/libvpx/libvpx_srcs.gni
+++ b/chromium/third_party/libvpx/libvpx_srcs.gni
@@ -190,16 +190,8 @@ libvpx_srcs_x86 = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -362,6 +354,7 @@ libvpx_srcs_x86 = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -667,16 +660,8 @@ libvpx_srcs_x86_64 = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -839,6 +824,7 @@ libvpx_srcs_x86_64 = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -1147,16 +1133,8 @@ libvpx_srcs_arm = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -1301,6 +1279,7 @@ libvpx_srcs_arm = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -1517,16 +1496,8 @@ libvpx_srcs_arm_neon = [
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -1705,6 +1676,7 @@ libvpx_srcs_arm_neon = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -1916,16 +1888,8 @@ libvpx_srcs_arm_neon_cpu_detect = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -2076,6 +2040,7 @@ libvpx_srcs_arm_neon_cpu_detect = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -2364,16 +2329,8 @@ libvpx_srcs_arm64 = [
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -2556,6 +2513,7 @@ libvpx_srcs_arm64 = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -2774,16 +2732,8 @@ libvpx_srcs_arm_neon_highbd = [
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -2976,6 +2926,7 @@ libvpx_srcs_arm_neon_highbd = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -3213,16 +3164,8 @@ libvpx_srcs_arm64_highbd = [
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -3419,6 +3362,7 @@ libvpx_srcs_arm64_highbd = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -3608,16 +3552,8 @@ libvpx_srcs_mips = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -3761,6 +3697,7 @@ libvpx_srcs_mips = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -3950,16 +3887,8 @@ libvpx_srcs_nacl = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -4102,6 +4031,7 @@ libvpx_srcs_nacl = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
@@ -4291,16 +4221,8 @@ libvpx_srcs_generic = [
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.h",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_alt_ref_aq.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_360.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_complexity.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.c",
- "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_variance.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.h",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_block.h",
@@ -4443,6 +4365,7 @@ libvpx_srcs_generic = [
"//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h",
+ "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.c",
"//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h",
]
diff --git a/chromium/third_party/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h
index abd9cbd63d0..9c31497876c 100644
--- a/chromium/third_party/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h
@@ -1347,6 +1347,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h
index abd9cbd63d0..9c31497876c 100644
--- a/chromium/third_party/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h
@@ -1347,6 +1347,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h
index 0f5ae3eb1f4..95df12a235f 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h
@@ -1741,6 +1741,13 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h
index 24f335af3e7..71eb333a0bd 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h
@@ -4047,6 +4047,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h
index abd9cbd63d0..9c31497876c 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h
@@ -1347,6 +1347,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h
index dc7b59b79f8..792d50fbdef 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h
@@ -870,6 +870,13 @@ void vpx_sad32x32x4d_c(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_c
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h
index 24f335af3e7..71eb333a0bd 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h
@@ -4047,6 +4047,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h
index abd9cbd63d0..9c31497876c 100644
--- a/chromium/third_party/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h
@@ -1347,6 +1347,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h
index 7e5eb2cfe48..8ba4d88055d 100644
--- a/chromium/third_party/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h
@@ -3155,6 +3155,13 @@ void vpx_sad32x32x4d_c(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_c
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h
index 472c624d26a..096e3a863e5 100644
--- a/chromium/third_party/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h
@@ -5856,6 +5856,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7843,6 +7859,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h
index b406c882633..63a0f75b874 100644
--- a/chromium/third_party/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h
@@ -870,6 +870,13 @@ void vpx_sad32x32x4d_c(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_c
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h
index b406c882633..63a0f75b874 100644
--- a/chromium/third_party/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h
@@ -870,6 +870,13 @@ void vpx_sad32x32x4d_c(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_c
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h
index 7021eaa522a..ed632331485 100644
--- a/chromium/third_party/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h
@@ -5933,6 +5933,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7923,6 +7939,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h
index 472c624d26a..096e3a863e5 100644
--- a/chromium/third_party/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h
@@ -5856,6 +5856,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7843,6 +7859,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h
index 7021eaa522a..ed632331485 100644
--- a/chromium/third_party/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h
@@ -5933,6 +5933,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7923,6 +7939,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/config/nacl/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/nacl/vpx_dsp_rtcd.h
index 7e5eb2cfe48..8ba4d88055d 100644
--- a/chromium/third_party/libvpx/source/config/nacl/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/nacl/vpx_dsp_rtcd.h
@@ -3155,6 +3155,13 @@ void vpx_sad32x32x4d_c(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_c
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/vpx_version.h b/chromium/third_party/libvpx/source/config/vpx_version.h
index ad2a19a4ba5..e481f5e3c83 100644
--- a/chromium/third_party/libvpx/source/config/vpx_version.h
+++ b/chromium/third_party/libvpx/source/config/vpx_version.h
@@ -1,8 +1,8 @@
// This file is generated. Do not edit.
#define VERSION_MAJOR 1
#define VERSION_MINOR 8
-#define VERSION_PATCH 0
-#define VERSION_EXTRA "508-g0308a9a132"
+#define VERSION_PATCH 1
+#define VERSION_EXTRA "53-g18d309c127"
#define VERSION_PACKED ((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH))
-#define VERSION_STRING_NOSP "v1.8.0-508-g0308a9a132"
-#define VERSION_STRING " v1.8.0-508-g0308a9a132"
+#define VERSION_STRING_NOSP "v1.8.1-53-g18d309c127"
+#define VERSION_STRING " v1.8.1-53-g18d309c127"
diff --git a/chromium/third_party/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h
index 24f335af3e7..71eb333a0bd 100644
--- a/chromium/third_party/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h
@@ -4047,6 +4047,13 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr,
uint32_t* sad_array);
#define vpx_sad32x32x4d vpx_sad32x32x4d_neon
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+#define vpx_sad32x32x8 vpx_sad32x32x8_c
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
diff --git a/chromium/third_party/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h
index 472c624d26a..096e3a863e5 100644
--- a/chromium/third_party/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h
@@ -5856,6 +5856,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7843,6 +7859,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/config/win/x64/vpx_dsp_rtcd.h b/chromium/third_party/libvpx/source/config/win/x64/vpx_dsp_rtcd.h
index 7021eaa522a..ed632331485 100644
--- a/chromium/third_party/libvpx/source/config/win/x64/vpx_dsp_rtcd.h
+++ b/chromium/third_party/libvpx/source/config/win/x64/vpx_dsp_rtcd.h
@@ -5933,6 +5933,22 @@ RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr,
int ref_stride,
uint32_t* sad_array);
+void vpx_sad32x32x8_c(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+void vpx_sad32x32x8_avx2(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+RTCD_EXTERN void (*vpx_sad32x32x8)(const uint8_t* src_ptr,
+ int src_stride,
+ const uint8_t* ref_ptr,
+ int ref_stride,
+ uint32_t* sad_array);
+
unsigned int vpx_sad32x64_c(const uint8_t* src_ptr,
int src_stride,
const uint8_t* ref_ptr,
@@ -7923,6 +7939,9 @@ static void setup_rtcd_internal(void) {
vpx_sad32x32x4d = vpx_sad32x32x4d_sse2;
if (flags & HAS_AVX2)
vpx_sad32x32x4d = vpx_sad32x32x4d_avx2;
+ vpx_sad32x32x8 = vpx_sad32x32x8_c;
+ if (flags & HAS_AVX2)
+ vpx_sad32x32x8 = vpx_sad32x32x8_avx2;
vpx_sad32x64 = vpx_sad32x64_sse2;
if (flags & HAS_AVX2)
vpx_sad32x64 = vpx_sad32x64_avx2;
diff --git a/chromium/third_party/libvpx/source/libvpx/.mailmap b/chromium/third_party/libvpx/source/libvpx/.mailmap
index 7c26790b8e5..465f12ad768 100644
--- a/chromium/third_party/libvpx/source/libvpx/.mailmap
+++ b/chromium/third_party/libvpx/source/libvpx/.mailmap
@@ -24,6 +24,7 @@ Joshua Litt <joshualitt@google.com> <joshualitt@chromium.org>
Marco Paniconi <marpan@google.com>
Marco Paniconi <marpan@google.com> <marpan@chromium.org>
Martin Storsjö <martin@martin.st>
+Michael Horowitz <mhoro@webrtc.org> <mhoro@google.com>
Pascal Massimino <pascal.massimino@gmail.com>
Paul Wilkins <paulwilkins@google.com>
Peter Boström <pbos@chromium.org> <pbos@google.com>
@@ -45,4 +46,5 @@ Urvang Joshi <urvang@google.com> <urvang@chromium.org>
Yaowu Xu <yaowu@google.com> <adam@xuyaowu.com>
Yaowu Xu <yaowu@google.com> <yaowu@xuyaowu.com>
Yaowu Xu <yaowu@google.com> <Yaowu Xu>
+Venkatarama NG. Avadhani <venkatarama.avadhani@ittiam.com>
xiwei gu <guxiwei-hf@loongson.cn>
diff --git a/chromium/third_party/libvpx/source/libvpx/AUTHORS b/chromium/third_party/libvpx/source/libvpx/AUTHORS
index 3f7a86dcd08..2f1f8a6946a 100644
--- a/chromium/third_party/libvpx/source/libvpx/AUTHORS
+++ b/chromium/third_party/libvpx/source/libvpx/AUTHORS
@@ -4,12 +4,13 @@
Aaron Watry <awatry@gmail.com>
Abo Talib Mahfoodh <ab.mahfoodh@gmail.com>
Adrian Grange <agrange@google.com>
-Aâ„“ex Converse <aconverse@google.com>
Ahmad Sharif <asharif@google.com>
+Aidan Welch <aidansw@yahoo.com>
Aleksey Vasenev <margtu-fivt@ya.ru>
Alexander Potapenko <glider@google.com>
Alexander Voronov <avoronov@graphics.cs.msu.ru>
Alexandra HĂ¡jkovĂ¡ <alexandra.khirnova@gmail.com>
+Aâ„“ex Converse <aconverse@google.com>
Alexis Ballier <aballier@gentoo.org>
Alok Ahuja <waveletcoeff@gmail.com>
Alpha Lam <hclam@google.com>
@@ -32,6 +33,7 @@ Chris Cunningham <chcunningham@chromium.org>
Christian Duvivier <cduvivier@google.com>
Daniele Castagna <dcastagna@chromium.org>
Daniel Kang <ddkang@google.com>
+Dan Zhu <zxdan@google.com>
Deb Mukherjee <debargha@google.com>
Deepa K G <deepa.kg@ittiam.com>
Dim Temp <dimtemp0@gmail.com>
@@ -60,6 +62,7 @@ Hanno Böck <hanno@hboeck.de>
Han Shen <shenhan@google.com>
Harish Mahendrakar <harish.mahendrakar@ittiam.com>
Henrik Lundin <hlundin@google.com>
+Hien Ho <hienho@google.com>
Hui Su <huisu@google.com>
Ivan Krasin <krasin@chromium.org>
Ivan Maltz <ivanmaltz@google.com>
@@ -108,6 +111,7 @@ Martin Ettl <ettl.martin78@googlemail.com>
Martin Storsjö <martin@martin.st>
Matthew Heaney <matthewjheaney@chromium.org>
Matthias Räncker <theonetruecamper@gmx.de>
+Michael Horowitz <mhoro@webrtc.org>
Michael Kohler <michaelkohler@live.com>
Mike Frysinger <vapier@chromium.org>
Mike Hommey <mhommey@mozilla.com>
@@ -140,6 +144,7 @@ Rahul Chaudhry <rahulchaudhry@google.com>
Ralph Giles <giles@xiph.org>
Ranjit Kumar Tulabandu <ranjit.tulabandu@ittiam.com>
Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
+Ravi Chaudhary <ravi.chaudhary@ittiam.com>
Ritu Baldwa <ritu.baldwa@ittiam.com>
Rob Bradford <rob@linux.intel.com>
Ronald S. Bultje <rsbultje@gmail.com>
@@ -181,6 +186,7 @@ xiwei gu <guxiwei-hf@loongson.cn>
Yaowu Xu <yaowu@google.com>
Yi Luo <luoyi@google.com>
Yongzhe Wang <yongzhe@google.com>
+Yue Chen <yuec@google.com>
Yunqing Wang <yunqingwang@google.com>
Yury Gitman <yuryg@google.com>
Zoe Liu <zoeliu@google.com>
diff --git a/chromium/third_party/libvpx/source/libvpx/CHANGELOG b/chromium/third_party/libvpx/source/libvpx/CHANGELOG
index 3bdf8acfb1e..a7d8311c5f9 100644
--- a/chromium/third_party/libvpx/source/libvpx/CHANGELOG
+++ b/chromium/third_party/libvpx/source/libvpx/CHANGELOG
@@ -1,3 +1,21 @@
+2019-07-15 v1.8.1 "Orpington Duck"
+ This release collects incremental improvements to many aspects of the library.
+
+ - Upgrading:
+ VP8E_SET_CPUUSED now accepts values up to 9 for vp9.
+ VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT had a spelling fix (was VP8E).
+ The --sdk-path option has been removed. If you were using it to build for
+ Android please read build/make/Android.mk for alternatives.
+ All PPC optimizations have been disabled:
+ https://bugs.chromium.org/p/webm/issues/detail?id=1522.
+
+ - Enhancements:
+ Various changes to improve encoder rate control, quality and speed
+ for practically every use case.
+
+ - Bug fixes:
+ vp9-rtc: Fix color artifacts for speed >= 8.
+
2019-01-31 v1.8.0 "Northern Shoveler Duck"
This release focused on encoding performance for realtime and VOD use cases.
diff --git a/chromium/third_party/libvpx/source/libvpx/README b/chromium/third_party/libvpx/source/libvpx/README
index 61bee3e69c8..a1000e08509 100644
--- a/chromium/third_party/libvpx/source/libvpx/README
+++ b/chromium/third_party/libvpx/source/libvpx/README
@@ -1,4 +1,4 @@
-README - 31 January 2019
+README - 15 July 2019
Welcome to the WebM VP8/VP9 Codec SDK!
diff --git a/chromium/third_party/libvpx/source/libvpx/build/make/configure.sh b/chromium/third_party/libvpx/source/libvpx/build/make/configure.sh
index 8f2928a9dd6..472e7dea7b1 100644
--- a/chromium/third_party/libvpx/source/libvpx/build/make/configure.sh
+++ b/chromium/third_party/libvpx/source/libvpx/build/make/configure.sh
@@ -507,6 +507,7 @@ AS_SFX = ${AS_SFX:-.asm}
EXE_SFX = ${EXE_SFX}
VCPROJ_SFX = ${VCPROJ_SFX}
RTCD_OPTIONS = ${RTCD_OPTIONS}
+LIBYUV_CXXFLAGS = ${LIBYUV_CXXFLAGS}
EOF
if enabled rvct; then cat >> $1 << EOF
@@ -1238,7 +1239,9 @@ EOF
ppc64le*)
link_with_cc=gcc
setup_gnu_toolchain
- check_gcc_machine_option "vsx"
+ # Do not enable vsx by default.
+ # https://bugs.chromium.org/p/webm/issues/detail?id=1522
+ enabled vsx || RTCD_OPTIONS="${RTCD_OPTIONS}--disable-vsx "
if [ -n "${tune_cpu}" ]; then
case ${tune_cpu} in
power?)
diff --git a/chromium/third_party/libvpx/source/libvpx/configure b/chromium/third_party/libvpx/source/libvpx/configure
index 5e7c50ad3f3..d29e00ad86b 100755
--- a/chromium/third_party/libvpx/source/libvpx/configure
+++ b/chromium/third_party/libvpx/source/libvpx/configure
@@ -620,6 +620,8 @@ process_toolchain() {
check_add_cflags -Wcast-qual
check_add_cflags -Wvla
check_add_cflags -Wimplicit-function-declaration
+ check_add_cflags -Wmissing-declarations
+ check_add_cflags -Wmissing-prototypes
check_add_cflags -Wuninitialized
check_add_cflags -Wunused
check_add_cflags -Wextra
@@ -628,10 +630,6 @@ process_toolchain() {
check_cflags -Wundef && add_cflags_only -Wundef
check_cflags -Wframe-larger-than=52000 && \
add_cflags_only -Wframe-larger-than=52000
- check_cflags -Wmissing-declarations && \
- add_cflags_only -Wmissing-declarations
- check_cflags -Wmissing-prototypes && \
- add_cflags_only -Wmissing-prototypes
if enabled mips || [ -z "${INLINE}" ]; then
enabled extra_warnings || check_add_cflags -Wno-unused-function
fi
@@ -647,6 +645,14 @@ process_toolchain() {
if enabled arm; then
check_add_cxxflags -Wno-psabi
fi
+
+ # disable some warnings specific to libyuv.
+ check_cxxflags -Wno-missing-declarations \
+ && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-declarations"
+ check_cxxflags -Wno-missing-prototypes \
+ && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-prototypes"
+ check_cxxflags -Wno-unused-parameter \
+ && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-unused-parameter"
fi
if enabled icc; then
diff --git a/chromium/third_party/libvpx/source/libvpx/examples.mk b/chromium/third_party/libvpx/source/libvpx/examples.mk
index e0da4caa26e..758ca7f8894 100644
--- a/chromium/third_party/libvpx/source/libvpx/examples.mk
+++ b/chromium/third_party/libvpx/source/libvpx/examples.mk
@@ -77,7 +77,7 @@ vpxdec.SRCS += tools_common.c tools_common.h
vpxdec.SRCS += y4menc.c y4menc.h
ifeq ($(CONFIG_LIBYUV),yes)
vpxdec.SRCS += $(LIBYUV_SRCS)
- $(BUILD_PFX)third_party/libyuv/%.cc.o: CXXFLAGS += -Wno-unused-parameter
+ $(BUILD_PFX)third_party/libyuv/%.cc.o: CXXFLAGS += ${LIBYUV_CXXFLAGS}
endif
ifeq ($(CONFIG_WEBM_IO),yes)
vpxdec.SRCS += $(LIBWEBM_COMMON_SRCS)
diff --git a/chromium/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc b/chromium/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc
index e3b0d2e0af0..d55fe1571be 100644
--- a/chromium/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc
+++ b/chromium/third_party/libvpx/source/libvpx/examples/vpx_dec_fuzzer.cc
@@ -32,7 +32,8 @@
* Note --size-limit and VPX_MAX_ALLOCABLE_MEMORY are defined to avoid
* Out of memory errors when running generated fuzzer binary
$../libvpx/configure --disable-unit-tests --size-limit=12288x12288 \
- --extra-cflags="-DVPX_MAX_ALLOCABLE_MEMORY=1073741824" \
+ --extra-cflags="-fsanitize=fuzzer-no-link \
+ -DVPX_MAX_ALLOCABLE_MEMORY=1073741824" \
--disable-webm-io --enable-debug --disable-vp8-encoder \
--disable-vp9-encoder --disable-examples
@@ -65,6 +66,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <algorithm>
#include <memory>
#include "vpx/vp8dx.h"
@@ -77,61 +79,10 @@
#define VPXD_INTERFACE(name) VPXD_INTERFACE_(name)
#define VPXD_INTERFACE_(name) vpx_codec_##name##_dx()
-static void CloseFile(FILE *file) { fclose(file); }
-
-/* ReadFrame is derived from ivf_read_frame in ivfdec.c
- * This function doesn't call warn(), but instead ignores those errors.
- * This is done to minimize the prints on console when running fuzzer
- * Also if fread fails to read frame_size number of bytes, instead of
- * returning an error, this returns with partial frames.
- * This is done to ensure that partial frames are sent to decoder.
- */
-static int ReadFrame(FILE *infile, uint8_t **buffer, size_t *bytes_read,
- size_t *buffer_size) {
- char raw_header[IVF_FRAME_HDR_SZ] = { 0 };
- size_t frame_size = 0;
-
- if (fread(raw_header, IVF_FRAME_HDR_SZ, 1, infile) == 1) {
- frame_size = mem_get_le32(raw_header);
-
- if (frame_size > 256 * 1024 * 1024) {
- frame_size = 0;
- }
-
- if (frame_size > *buffer_size) {
- uint8_t *new_buffer = (uint8_t *)realloc(*buffer, 2 * frame_size);
-
- if (new_buffer) {
- *buffer = new_buffer;
- *buffer_size = 2 * frame_size;
- } else {
- frame_size = 0;
- }
- }
- }
-
- if (!feof(infile)) {
- *bytes_read = fread(*buffer, 1, frame_size, infile);
- return 0;
- }
-
- return 1;
-}
-
extern "C" void usage_exit(void) { exit(EXIT_FAILURE); }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- std::unique_ptr<FILE, decltype(&CloseFile)> file(
- fmemopen((void *)data, size, "rb"), &CloseFile);
- if (file == nullptr) {
- return 0;
- }
- // Ensure input contains at least one file header and one frame header
- if (size < IVF_FILE_HDR_SZ + IVF_FRAME_HDR_SZ) {
- return 0;
- }
- char header[IVF_FILE_HDR_SZ];
- if (fread(header, 1, IVF_FILE_HDR_SZ, file.get()) != IVF_FILE_HDR_SZ) {
+ if (size <= IVF_FILE_HDR_SZ) {
return 0;
}
@@ -143,20 +94,25 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}
- uint8_t *buffer = nullptr;
- size_t buffer_size = 0;
- size_t frame_size = 0;
+ data += IVF_FILE_HDR_SZ;
+ size -= IVF_FILE_HDR_SZ;
+
+ while (size > IVF_FRAME_HDR_SZ) {
+ size_t frame_size = mem_get_le32(data);
+ size -= IVF_FRAME_HDR_SZ;
+ data += IVF_FRAME_HDR_SZ;
+ frame_size = std::min(size, frame_size);
- while (!ReadFrame(file.get(), &buffer, &frame_size, &buffer_size)) {
const vpx_codec_err_t err =
- vpx_codec_decode(&codec, buffer, frame_size, nullptr, 0);
+ vpx_codec_decode(&codec, data, frame_size, nullptr, 0);
static_cast<void>(err);
vpx_codec_iter_t iter = nullptr;
vpx_image_t *img = nullptr;
while ((img = vpx_codec_get_frame(&codec, &iter)) != nullptr) {
}
+ data += frame_size;
+ size -= frame_size;
}
vpx_codec_destroy(&codec);
- free(buffer);
return 0;
}
diff --git a/chromium/third_party/libvpx/source/libvpx/libs.mk b/chromium/third_party/libvpx/source/libvpx/libs.mk
index d0c4d6426a3..67d7512abea 100644
--- a/chromium/third_party/libvpx/source/libvpx/libs.mk
+++ b/chromium/third_party/libvpx/source/libvpx/libs.mk
@@ -145,7 +145,6 @@ INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += vpx_dsp/x86/bitdepth_conversion_sse2.asm
endif
CODEC_EXPORTS-yes += vpx/exports_com
CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
-CODEC_EXPORTS-$(CONFIG_VP9_ENCODER) += vpx/exports_spatial_svc
CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
INSTALL-LIBS-yes += include/vpx/vpx_codec.h
@@ -234,7 +233,7 @@ LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
SO_VERSION_MAJOR := 6
-SO_VERSION_MINOR := 0
+SO_VERSION_MINOR := 1
SO_VERSION_PATCH := 0
ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
diff --git a/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx b/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx
index 16f17513e72..714f5d0eb5a 100644
--- a/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx
+++ b/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/README.libvpx
@@ -1,5 +1,5 @@
URL: https://chromium.googlesource.com/webm/libwebm
-Version: dbf1d1089756e7cb5b1a04d6752310ef35912347
+Version: 81de00c43ea3c087b48a8c20337db7531b9f7612
License: BSD
License File: LICENSE.txt
diff --git a/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc b/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc
index dcb969dcf51..ace65bd5957 100644
--- a/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc
+++ b/chromium/third_party/libvpx/source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc
@@ -4230,6 +4230,7 @@ long ContentEncoding::ParseContentEncodingEntry(long long start, long long size,
new (std::nothrow) ContentEncryption*[encryption_count];
if (!encryption_entries_) {
delete[] compression_entries_;
+ compression_entries_ = NULL;
return -1;
}
encryption_entries_end_ = encryption_entries_;
@@ -4261,6 +4262,7 @@ long ContentEncoding::ParseContentEncodingEntry(long long start, long long size,
delete compression;
return status;
}
+ assert(compression_count > 0);
*compression_entries_end_++ = compression;
} else if (id == libwebm::kMkvContentEncryption) {
ContentEncryption* const encryption =
@@ -4273,6 +4275,7 @@ long ContentEncoding::ParseContentEncodingEntry(long long start, long long size,
delete encryption;
return status;
}
+ assert(encryption_count > 0);
*encryption_entries_end_++ = encryption;
}
@@ -4325,6 +4328,12 @@ long ContentEncoding::ParseCompressionEntry(long long start, long long size,
return status;
}
+ // There should be only one settings element per content compression.
+ if (compression->settings != NULL) {
+ delete[] buf;
+ return E_FILE_FORMAT_INVALID;
+ }
+
compression->settings = buf;
compression->settings_len = buflen;
}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py
new file mode 100644
index 00000000000..3c0346814bc
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Exhaust.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+# coding: utf-8
+import numpy as np
+import numpy.linalg as LA
+from Util import MSE
+from MotionEST import MotionEST
+"""Exhaust Search:"""
+
+
+class Exhaust(MotionEST):
+ """
+ Constructor:
+ cur_f: current frame
+ ref_f: reference frame
+ blk_sz: block size
+ wnd_size: search window size
+ metric: metric to compare the blocks distrotion
+ """
+
+ def __init__(self, cur_f, ref_f, blk_size, wnd_size, metric=MSE):
+ self.name = 'exhaust'
+ self.wnd_sz = wnd_size
+ self.metric = metric
+ super(Exhaust, self).__init__(cur_f, ref_f, blk_size)
+
+ """
+ search method:
+ cur_r: start row
+ cur_c: start column
+ """
+
+ def search(self, cur_r, cur_c):
+ min_loss = self.dist(cur_r, cur_c, [0, 0], self.metric)
+ cur_x = cur_c * self.blk_sz
+ cur_y = cur_r * self.blk_sz
+ ref_x = cur_x
+ ref_y = cur_y
+ #search all validate positions and select the one with minimum distortion
+ for y in xrange(cur_y - self.wnd_sz, cur_y + self.wnd_sz):
+ for x in xrange(cur_x - self.wnd_sz, cur_x + self.wnd_sz):
+ if 0 <= x < self.width - self.blk_sz and 0 <= y < self.height - self.blk_sz:
+ loss = self.dist(cur_r, cur_c, [y - cur_y, x - cur_x], self.metric)
+ if loss < min_loss:
+ min_loss = loss
+ ref_x = x
+ ref_y = y
+ return ref_x, ref_y
+
+ def est(self):
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ ref_x, ref_y = self.search(i, j)
+ self.mf[i, j] = np.array(
+ [ref_y - i * self.blk_sz, ref_x - j * self.blk_sz])
+
+
+"""Exhaust with Neighbor Constraint"""
+
+
+class ExhaustNeighbor(MotionEST):
+ """
+ Constructor:
+ cur_f: current frame
+ ref_f: reference frame
+ blk_sz: block size
+ wnd_size: search window size
+ beta: neigbor loss weight
+ metric: metric to compare the blocks distrotion
+ """
+
+ def __init__(self, cur_f, ref_f, blk_size, wnd_size, beta, metric=MSE):
+ self.name = 'exhaust + neighbor'
+ self.wnd_sz = wnd_size
+ self.beta = beta
+ self.metric = metric
+ super(ExhaustNeighbor, self).__init__(cur_f, ref_f, blk_size)
+ self.assign = np.zeros((self.num_row, self.num_col), dtype=np.bool)
+
+ """
+ estimate neighbor loss:
+ cur_r: current row
+ cur_c: current column
+ mv: current motion vector
+ """
+
+ def neighborLoss(self, cur_r, cur_c, mv):
+ loss = 0
+ #accumulate difference between current block's motion vector with neighbors'
+ for i, j in {(-1, 0), (1, 0), (0, 1), (0, -1)}:
+ nb_r = cur_r + i
+ nb_c = cur_c + j
+ if 0 <= nb_r < self.num_row and 0 <= nb_c < self.num_col and self.assign[
+ nb_r, nb_c]:
+ loss += LA.norm(mv - self.mf[nb_r, nb_c])
+ return loss
+
+ """
+ search method:
+ cur_r: start row
+ cur_c: start column
+ """
+
+ def search(self, cur_r, cur_c):
+ dist_loss = self.dist(cur_r, cur_c, [0, 0], self.metric)
+ nb_loss = self.neighborLoss(cur_r, cur_c, np.array([0, 0]))
+ min_loss = dist_loss + self.beta * nb_loss
+ cur_x = cur_c * self.blk_sz
+ cur_y = cur_r * self.blk_sz
+ ref_x = cur_x
+ ref_y = cur_y
+ #search all validate positions and select the one with minimum distortion
+ # as well as weighted neighbor loss
+ for y in xrange(cur_y - self.wnd_sz, cur_y + self.wnd_sz):
+ for x in xrange(cur_x - self.wnd_sz, cur_x + self.wnd_sz):
+ if 0 <= x < self.width - self.blk_sz and 0 <= y < self.height - self.blk_sz:
+ dist_loss = self.dist(cur_r, cur_c, [y - cur_y, x - cur_x],
+ self.metric)
+ nb_loss = self.neighborLoss(cur_r, cur_c, [y - cur_y, x - cur_x])
+ loss = dist_loss + self.beta * nb_loss
+ if loss < min_loss:
+ min_loss = loss
+ ref_x = x
+ ref_y = y
+ return ref_x, ref_y
+
+ def est(self):
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ ref_x, ref_y = self.search(i, j)
+ self.mf[i, j] = np.array(
+ [ref_y - i * self.blk_sz, ref_x - j * self.blk_sz])
+ self.assign[i, j] = True
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py
new file mode 100644
index 00000000000..61b4bef4255
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/GroundTruth.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# coding: utf-8
+import numpy as np
+import numpy.linalg as LA
+from MotionEST import MotionEST
+"""Ground Truth:
+
+ Load in ground truth motion field and mask
+"""
+
+
+class GroundTruth(MotionEST):
+ """
+ constructor:
+ cur_f: current frame
+ ref_f: reference frame
+ blk_sz: block size
+ gt_path: ground truth motion field file path
+ """
+
+ def __init__(self, cur_f, ref_f, blk_sz, gt_path):
+ self.name = 'ground truth'
+ super(GroundTruth, self).__init__(cur_f, ref_f, blk_sz)
+ self.mask = np.zeros((self.num_row, self.num_col), dtype=np.bool)
+ with open(gt_path) as gt_file:
+ lines = gt_file.readlines()
+ for i in xrange(len(lines)):
+ info = lines[i].split(';')
+ for j in xrange(len(info)):
+ x, y = info[j].split(',')
+ #-,- stands for nothing
+ if x == '-' or y == '-':
+ self.mask[i, -j - 1] = True
+ continue
+ #the order of original file is flipped on the x axis
+ self.mf[i, -j - 1] = np.array([float(y), -float(x)], dtype=np.int)
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py
new file mode 100644
index 00000000000..0bf431cf6be
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/HornSchunck.py
@@ -0,0 +1,205 @@
+#!/usr/bin/env python
+# coding: utf-8
+import numpy as np
+import numpy.linalg as LA
+from scipy.ndimage.filters import gaussian_filter
+from scipy.sparse import csc_matrix
+from scipy.sparse.linalg import inv
+from MotionEST import MotionEST
+"""Horn & Schunck Model"""
+
+
+class HornSchunck(MotionEST):
+ """
+ constructor:
+ cur_f: current frame
+ ref_f: reference frame
+ blk_sz: block size
+ alpha: smooth constrain weight
+ sigma: gaussian blur parameter
+ """
+
+ def __init__(self, cur_f, ref_f, blk_sz, alpha, sigma, max_iter=100):
+ super(HornSchunck, self).__init__(cur_f, ref_f, blk_sz)
+ self.cur_I, self.ref_I = self.getIntensity()
+ #perform gaussian blur to smooth the intensity
+ self.cur_I = gaussian_filter(self.cur_I, sigma=sigma)
+ self.ref_I = gaussian_filter(self.ref_I, sigma=sigma)
+ self.alpha = alpha
+ self.max_iter = max_iter
+ self.Ix, self.Iy, self.It = self.intensityDiff()
+
+ """
+ Build Frame Intensity
+ """
+
+ def getIntensity(self):
+ cur_I = np.zeros((self.num_row, self.num_col))
+ ref_I = np.zeros((self.num_row, self.num_col))
+ #use average intensity as block's intensity
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ r = i * self.blk_sz
+ c = j * self.blk_sz
+ cur_I[i, j] = np.mean(self.cur_yuv[r:r + self.blk_sz, c:c + self.blk_sz,
+ 0])
+ ref_I[i, j] = np.mean(self.ref_yuv[r:r + self.blk_sz, c:c + self.blk_sz,
+ 0])
+ return cur_I, ref_I
+
+ """
+ Get First Order Derivative
+ """
+
+ def intensityDiff(self):
+ Ix = np.zeros((self.num_row, self.num_col))
+ Iy = np.zeros((self.num_row, self.num_col))
+ It = np.zeros((self.num_row, self.num_col))
+ sz = self.blk_sz
+ for i in xrange(self.num_row - 1):
+ for j in xrange(self.num_col - 1):
+ """
+ Ix:
+ (i ,j) <--- (i ,j+1)
+ (i+1,j) <--- (i+1,j+1)
+ """
+ count = 0
+ for r, c in {(i, j + 1), (i + 1, j + 1)}:
+ if 0 <= r < self.num_row and 0 < c < self.num_col:
+ Ix[i, j] += (
+ self.cur_I[r, c] - self.cur_I[r, c - 1] + self.ref_I[r, c] -
+ self.ref_I[r, c - 1])
+ count += 2
+ Ix[i, j] /= count
+ """
+ Iy:
+ (i ,j) (i ,j+1)
+ ^ ^
+ | |
+ (i+1,j) (i+1,j+1)
+ """
+ count = 0
+ for r, c in {(i + 1, j), (i + 1, j + 1)}:
+ if 0 < r < self.num_row and 0 <= c < self.num_col:
+ Iy[i, j] += (
+ self.cur_I[r, c] - self.cur_I[r - 1, c] + self.ref_I[r, c] -
+ self.ref_I[r - 1, c])
+ count += 2
+ Iy[i, j] /= count
+ count = 0
+ #It:
+ for r in xrange(i, i + 2):
+ for c in xrange(j, j + 2):
+ if 0 <= r < self.num_row and 0 <= c < self.num_col:
+ It[i, j] += (self.ref_I[r, c] - self.cur_I[r, c])
+ count += 1
+ It[i, j] /= count
+ return Ix, Iy, It
+
+ """
+ Get weighted average of neighbor motion vectors
+ for evaluation of laplacian
+ """
+
+ def averageMV(self):
+ avg = np.zeros((self.num_row, self.num_col, 2))
+ """
+ 1/12 --- 1/6 --- 1/12
+ | | |
+ 1/6 --- -1/8 --- 1/6
+ | | |
+ 1/12 --- 1/6 --- 1/12
+ """
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ for r, c in {(-1, 0), (1, 0), (0, -1), (0, 1)}:
+ if 0 <= i + r < self.num_row and 0 <= j + c < self.num_col:
+ avg[i, j] += self.mf[i + r, j + c] / 6.0
+ for r, c in {(-1, -1), (-1, 1), (1, -1), (1, 1)}:
+ if 0 <= i + r < self.num_row and 0 <= j + c < self.num_col:
+ avg[i, j] += self.mf[i + r, j + c] / 12.0
+ return avg
+
+ def est(self):
+ count = 0
+ """
+ u_{n+1} = ~u_n - Ix(Ix.~u_n+Iy.~v+It)/(IxIx+IyIy+alpha^2)
+ v_{n+1} = ~v_n - Iy(Ix.~u_n+Iy.~v+It)/(IxIx+IyIy+alpha^2)
+ """
+ denom = self.alpha**2 + np.power(self.Ix, 2) + np.power(self.Iy, 2)
+ while count < self.max_iter:
+ avg = self.averageMV()
+ self.mf[:, :, 1] = avg[:, :, 1] - self.Ix * (
+ self.Ix * avg[:, :, 1] + self.Iy * avg[:, :, 0] + self.It) / denom
+ self.mf[:, :, 0] = avg[:, :, 0] - self.Iy * (
+ self.Ix * avg[:, :, 1] + self.Iy * avg[:, :, 0] + self.It) / denom
+ count += 1
+ self.mf *= self.blk_sz
+
+ def est_mat(self):
+ row_idx = []
+ col_idx = []
+ data = []
+
+ N = 2 * self.num_row * self.num_col
+ b = np.zeros((N, 1))
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ """(IxIx+alpha^2)u+IxIy.v-alpha^2~u IxIy.u+(IyIy+alpha^2)v-alpha^2~v
+ """
+ u_idx = i * 2 * self.num_col + 2 * j
+ v_idx = u_idx + 1
+ b[u_idx, 0] = -self.Ix[i, j] * self.It[i, j]
+ b[v_idx, 0] = -self.Iy[i, j] * self.It[i, j]
+ #u: (IxIx+alpha^2)u
+ row_idx.append(u_idx)
+ col_idx.append(u_idx)
+ data.append(self.Ix[i, j] * self.Ix[i, j] + self.alpha**2)
+ #IxIy.v
+ row_idx.append(u_idx)
+ col_idx.append(v_idx)
+ data.append(self.Ix[i, j] * self.Iy[i, j])
+
+ #v: IxIy.u
+ row_idx.append(v_idx)
+ col_idx.append(u_idx)
+ data.append(self.Ix[i, j] * self.Iy[i, j])
+ #(IyIy+alpha^2)v
+ row_idx.append(v_idx)
+ col_idx.append(v_idx)
+ data.append(self.Iy[i, j] * self.Iy[i, j] + self.alpha**2)
+
+ #-alpha^2~u
+ #-alpha^2~v
+ for r, c in {(-1, 0), (1, 0), (0, -1), (0, 1)}:
+ if 0 <= i + r < self.num_row and 0 <= j + c < self.num_col:
+ u_nb = (i + r) * 2 * self.num_col + 2 * (j + c)
+ v_nb = u_nb + 1
+
+ row_idx.append(u_idx)
+ col_idx.append(u_nb)
+ data.append(-1 * self.alpha**2 / 6.0)
+
+ row_idx.append(v_idx)
+ col_idx.append(v_nb)
+ data.append(-1 * self.alpha**2 / 6.0)
+ for r, c in {(-1, -1), (-1, 1), (1, -1), (1, 1)}:
+ if 0 <= i + r < self.num_row and 0 <= j + c < self.num_col:
+ u_nb = (i + r) * 2 * self.num_col + 2 * (j + c)
+ v_nb = u_nb + 1
+
+ row_idx.append(u_idx)
+ col_idx.append(u_nb)
+ data.append(-1 * self.alpha**2 / 12.0)
+
+ row_idx.append(v_idx)
+ col_idx.append(v_nb)
+ data.append(-1 * self.alpha**2 / 12.0)
+ M = csc_matrix((data, (row_idx, col_idx)), shape=(N, N))
+ M_inv = inv(M)
+ uv = M_inv.dot(b)
+
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ self.mf[i, j, 0] = uv[i * 2 * self.num_col + 2 * j + 1, 0] * self.blk_sz
+ self.mf[i, j, 1] = uv[i * 2 * self.num_col + 2 * j, 0] * self.blk_sz
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py
new file mode 100644
index 00000000000..68cf7e7439d
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/MotionEST.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+# coding: utf-8
+import numpy as np
+import numpy.linalg as LA
+import matplotlib.pyplot as plt
+from Util import drawMF, MSE
+"""The Base Class of Estimators"""
+
+
+class MotionEST(object):
+ """
+ constructor:
+ cur_f: current frame
+ ref_f: reference frame
+ blk_sz: block size
+ """
+
+ def __init__(self, cur_f, ref_f, blk_sz):
+ self.cur_f = cur_f
+ self.ref_f = ref_f
+ self.blk_sz = blk_sz
+ #convert RGB to YUV
+ self.cur_yuv = np.array(self.cur_f.convert('YCbCr'))
+ self.ref_yuv = np.array(self.ref_f.convert('YCbCr'))
+ #frame size
+ self.width = self.cur_f.size[0]
+ self.height = self.cur_f.size[1]
+ #motion field size
+ self.num_row = self.height // self.blk_sz
+ self.num_col = self.width // self.blk_sz
+ #initialize motion field
+ self.mf = np.zeros((self.num_row, self.num_col, 2))
+
+ """
+ estimation function
+ Override by child classes
+ """
+
+ def motion_field_estimation(self):
+ pass
+
+ """
+ distortion of a block:
+ cur_r: current row
+ cur_c: current column
+ mv: motion vector
+ metric: distortion metric
+ """
+
+ def block_dist(self, cur_r, cur_c, mv, metric=MSE):
+ cur_x = cur_c * self.blk_sz
+ cur_y = cur_r * self.blk_sz
+ h = min(self.blk_sz, self.height - cur_y)
+ w = min(self.blk_sz, self.width - cur_x)
+ cur_blk = self.cur_yuv[cur_y:cur_y + h, cur_x:cur_x + w, :]
+ ref_x = int(cur_x + mv[1])
+ ref_y = int(cur_y + mv[0])
+ if 0 <= ref_x < self.width - w and 0 <= ref_y < self.height - h:
+ ref_blk = self.ref_yuv[ref_y:ref_y + h, ref_x:ref_x + w, :]
+ else:
+ ref_blk = np.zeros((h, w, 3))
+ return metric(cur_blk, ref_blk)
+
+ """
+ distortion of motion field
+ """
+
+ def distortion(self, mask=None, metric=MSE):
+ loss = 0
+ count = 0
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ if not mask is None and mask[i, j]:
+ continue
+ loss += self.dist(i, j, self.mf[i, j], metric)
+ count += 1
+ return loss / count
+
+ """
+ evaluation
+ compare the difference with ground truth
+ """
+
+ def motion_field_evaluation(self, ground_truth):
+ loss = 0
+ count = 0
+ gt = ground_truth.mf
+ mask = ground_truth.mask
+ for i in xrange(self.num_row):
+ for j in xrange(self.num_col):
+ if not mask is None and mask[i][j]:
+ continue
+ loss += LA.norm(gt[i, j] - self.mf[i, j])
+ count += 1
+ return loss / count
+
+ """
+ render the motion field
+ """
+
+ def show(self, ground_truth=None):
+ cur_mf = drawMF(self.cur_f, self.blk_sz, self.mf)
+ if ground_truth is None:
+ n_row = 1
+ else:
+ gt_mf = drawMF(self.cur_f, self.blk_sz, ground_truth)
+ n_row = 2
+ plt.figure(figsize=(n_row * 10, 10))
+ plt.subplot(1, n_row, 1)
+ plt.imshow(cur_mf)
+ plt.title('Estimated Motion Field')
+ if not ground_truth is None:
+ plt.subplot(1, n_row, 2)
+ plt.imshow(gt_mf)
+ plt.title('Ground Truth')
+ plt.tight_layout()
+ plt.show()
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py
new file mode 100644
index 00000000000..f1a0cd42fe1
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/MotionEST/Util.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# coding: utf-8
+import numpy as np
+import numpy.linalg as LA
+import matplotlib.pyplot as plt
+from scipy.ndimage import filters
+from PIL import Image, ImageDraw
+
+
+def MSE(blk1, blk2):
+ return np.mean(
+ LA.norm(
+ np.array(blk1, dtype=np.int) - np.array(blk2, dtype=np.int), axis=2))
+
+
+def drawMF(img, blk_sz, mf):
+ img_rgba = img.convert('RGBA')
+ mf_layer = Image.new(mode='RGBA', size=img_rgba.size, color=(0, 0, 0, 0))
+ draw = ImageDraw.Draw(mf_layer)
+ width = img_rgba.size[0]
+ height = img_rgba.size[1]
+ num_row = height // blk_sz
+ num_col = width // blk_sz
+ for i in xrange(num_row):
+ left = (0, i * blk_sz)
+ right = (width, i * blk_sz)
+ draw.line([left, right], fill=(0, 0, 255, 255))
+ for j in xrange(num_col):
+ up = (j * blk_sz, 0)
+ down = (j * blk_sz, height)
+ draw.line([up, down], fill=(0, 0, 255, 255))
+ for i in xrange(num_row):
+ for j in xrange(num_col):
+ center = (j * blk_sz + 0.5 * blk_sz, i * blk_sz + 0.5 * blk_sz)
+ head = (center[0] + mf[i, j][1], center[1] + mf[i, j][0])
+ draw.line([center, head], fill=(255, 0, 0, 255))
+ return Image.alpha_composite(img_rgba, mf_layer)
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py
new file mode 100644
index 00000000000..4b640e3e48a
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/genY4M/genY4M.py
@@ -0,0 +1,76 @@
+import argparse
+from os import listdir, path
+from PIL import Image
+import sys
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--frame_path", default="../data/frame/", type=str)
+parser.add_argument("--frame_rate", default="25:1", type=str)
+parser.add_argument("--interlacing", default="Ip", type=str)
+parser.add_argument("--pix_ratio", default="0:0", type=str)
+parser.add_argument("--color_space", default="4:2:0", type=str)
+parser.add_argument("--output", default="output.y4m", type=str)
+
+
+def generate(args, frames):
+ if len(frames) == 0:
+ return
+ #sort the frames based on the frame index
+ frames = sorted(frames, key=lambda x: x[0])
+ #convert the frames to YUV form
+ frames = [f.convert("YCbCr") for _, f in frames]
+ #write the header
+ header = "YUV4MPEG2 W%d H%d F%s %s A%s" % (frames[0].width, frames[0].height,
+ args.frame_rate, args.interlacing,
+ args.pix_ratio)
+ cs = args.color_space.split(":")
+ header += " C%s%s%s\n" % (cs[0], cs[1], cs[2])
+ #estimate the sample step based on subsample value
+ subsamples = [int(c) for c in cs]
+ r_step = [1, int(subsamples[2] == 0) + 1, int(subsamples[2] == 0) + 1]
+ c_step = [1, 4 // subsamples[1], 4 // subsamples[1]]
+ #write in frames
+ with open(args.output, "wb") as y4m:
+ y4m.write(header)
+ for f in frames:
+ y4m.write("FRAME\n")
+ px = f.load()
+ for k in xrange(3):
+ for i in xrange(0, f.height, r_step[k]):
+ for j in xrange(0, f.width, c_step[k]):
+ yuv = px[j, i]
+ y4m.write(chr(yuv[k]))
+
+
+if __name__ == "__main__":
+ args = parser.parse_args()
+ frames = []
+ frames_mv = []
+ for filename in listdir(args.frame_path):
+ name, ext = filename.split(".")
+ if ext == "png":
+ name_parse = name.split("_")
+ idx = int(name_parse[-1])
+ img = Image.open(path.join(args.frame_path, filename))
+ if name_parse[-2] == "mv":
+ frames_mv.append((idx, img))
+ else:
+ frames.append((idx, img))
+ if len(frames) == 0:
+ print "No frames in directory: " + args.frame_path
+ sys.exit()
+ print("----------------------Y4M Info----------------------")
+ print("width: %d" % frames[0][1].width)
+ print("height: %d" % frames[0][1].height)
+ print("#frame: %d" % len(frames))
+ print("frame rate: %s" % args.frame_rate)
+ print("interlacing: %s" % args.interlacing)
+ print("pixel ratio: %s" % args.pix_ratio)
+ print("color space: %s" % args.color_space)
+ print("----------------------------------------------------")
+
+ print("Generating ...")
+ generate(args, frames)
+ if len(frames_mv) != 0:
+ args.output = args.output.replace(".y4m", "_mv.y4m")
+ generate(args, frames_mv)
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde
new file mode 100644
index 00000000000..7249ee972eb
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/BVH.pde
@@ -0,0 +1,163 @@
+/*
+ *AABB bounding box
+ *Bouding Volume Hierarchy
+ */
+class BoundingBox {
+ float min_x, min_y, min_z, max_x, max_y, max_z;
+ PVector center;
+ BoundingBox() {
+ min_x = Float.POSITIVE_INFINITY;
+ min_y = Float.POSITIVE_INFINITY;
+ min_z = Float.POSITIVE_INFINITY;
+ max_x = Float.NEGATIVE_INFINITY;
+ max_y = Float.NEGATIVE_INFINITY;
+ max_z = Float.NEGATIVE_INFINITY;
+ center = new PVector();
+ }
+ // build a bounding box for a triangle
+ void create(Triangle t) {
+ min_x = min(t.p1.x, min(t.p2.x, t.p3.x));
+ max_x = max(t.p1.x, max(t.p2.x, t.p3.x));
+
+ min_y = min(t.p1.y, min(t.p2.y, t.p3.y));
+ max_y = max(t.p1.y, max(t.p2.y, t.p3.y));
+
+ min_z = min(t.p1.z, min(t.p2.z, t.p3.z));
+ max_z = max(t.p1.z, max(t.p2.z, t.p3.z));
+ center.x = (max_x + min_x) / 2;
+ center.y = (max_y + min_y) / 2;
+ center.z = (max_z + min_z) / 2;
+ }
+ // merge two bounding boxes
+ void add(BoundingBox bbx) {
+ min_x = min(min_x, bbx.min_x);
+ min_y = min(min_y, bbx.min_y);
+ min_z = min(min_z, bbx.min_z);
+
+ max_x = max(max_x, bbx.max_x);
+ max_y = max(max_y, bbx.max_y);
+ max_z = max(max_z, bbx.max_z);
+ center.x = (max_x + min_x) / 2;
+ center.y = (max_y + min_y) / 2;
+ center.z = (max_z + min_z) / 2;
+ }
+ // get bounding box center axis value
+ float getCenterAxisValue(int axis) {
+ if (axis == 1) {
+ return center.x;
+ } else if (axis == 2) {
+ return center.y;
+ }
+ // when axis == 3
+ return center.z;
+ }
+ // check if a ray is intersected with the bounding box
+ boolean intersect(Ray r) {
+ float tmin, tmax;
+ if (r.dir.x >= 0) {
+ tmin = (min_x - r.ori.x) * (1.0f / r.dir.x);
+ tmax = (max_x - r.ori.x) * (1.0f / r.dir.x);
+ } else {
+ tmin = (max_x - r.ori.x) * (1.0f / r.dir.x);
+ tmax = (min_x - r.ori.x) * (1.0f / r.dir.x);
+ }
+
+ float tymin, tymax;
+ if (r.dir.y >= 0) {
+ tymin = (min_y - r.ori.y) * (1.0f / r.dir.y);
+ tymax = (max_y - r.ori.y) * (1.0f / r.dir.y);
+ } else {
+ tymin = (max_y - r.ori.y) * (1.0f / r.dir.y);
+ tymax = (min_y - r.ori.y) * (1.0f / r.dir.y);
+ }
+
+ if (tmax < tymin || tymax < tmin) {
+ return false;
+ }
+
+ tmin = tmin < tymin ? tymin : tmin;
+ tmax = tmax > tymax ? tymax : tmax;
+
+ float tzmin, tzmax;
+ if (r.dir.z >= 0) {
+ tzmin = (min_z - r.ori.z) * (1.0f / r.dir.z);
+ tzmax = (max_z - r.ori.z) * (1.0f / r.dir.z);
+ } else {
+ tzmin = (max_z - r.ori.z) * (1.0f / r.dir.z);
+ tzmax = (min_z - r.ori.z) * (1.0f / r.dir.z);
+ }
+ if (tmax < tzmin || tmin > tzmax) {
+ return false;
+ }
+ return true;
+ }
+}
+// Bounding Volume Hierarchy
+class BVH {
+ // Binary Tree
+ BVH left, right;
+ BoundingBox overall_bbx;
+ ArrayList<Triangle> mesh;
+ BVH(ArrayList<Triangle> mesh) {
+ this.mesh = mesh;
+ overall_bbx = new BoundingBox();
+ left = null;
+ right = null;
+ int mesh_size = this.mesh.size();
+ if (mesh_size <= 1) {
+ return;
+ }
+ // random select an axis
+ int axis = int(random(100)) % 3 + 1;
+ // build bounding box and save the selected center component
+ float[] axis_values = new float[mesh_size];
+ for (int i = 0; i < mesh_size; i++) {
+ Triangle t = this.mesh.get(i);
+ overall_bbx.add(t.bbx);
+ axis_values[i] = t.bbx.getCenterAxisValue(axis);
+ }
+ // find the median value of selected center component as pivot
+ axis_values = sort(axis_values);
+ float pivot;
+ if (mesh_size % 2 == 1) {
+ pivot = axis_values[mesh_size / 2];
+ } else {
+ pivot =
+ 0.5f * (axis_values[mesh_size / 2 - 1] + axis_values[mesh_size / 2]);
+ }
+ // Build left node and right node by partitioning the mesh based on triangle
+ // bounding box center component value
+ ArrayList<Triangle> left_mesh = new ArrayList<Triangle>();
+ ArrayList<Triangle> right_mesh = new ArrayList<Triangle>();
+ for (int i = 0; i < mesh_size; i++) {
+ Triangle t = this.mesh.get(i);
+ if (t.bbx.getCenterAxisValue(axis) < pivot) {
+ left_mesh.add(t);
+ } else if (t.bbx.getCenterAxisValue(axis) > pivot) {
+ right_mesh.add(t);
+ } else if (left_mesh.size() < right_mesh.size()) {
+ left_mesh.add(t);
+ } else {
+ right_mesh.add(t);
+ }
+ }
+ left = new BVH(left_mesh);
+ right = new BVH(right_mesh);
+ }
+ // check if a ray intersect with current volume
+ boolean intersect(Ray r, float[] param) {
+ if (mesh.size() == 0) {
+ return false;
+ }
+ if (mesh.size() == 1) {
+ Triangle t = mesh.get(0);
+ return t.intersect(r, param);
+ }
+ if (!overall_bbx.intersect(r)) {
+ return false;
+ }
+ boolean left_res = left.intersect(r, param);
+ boolean right_res = right.intersect(r, param);
+ return left_res || right_res;
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde
new file mode 100644
index 00000000000..b39dae3a195
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Camera.pde
@@ -0,0 +1,138 @@
+class Camera {
+ // camera's field of view
+ float fov;
+ // camera's position, look at point and axis
+ PVector pos, center, axis;
+ PVector init_pos, init_center, init_axis;
+ float move_speed;
+ float rot_speed;
+ Camera(float fov, PVector pos, PVector center, PVector axis) {
+ this.fov = fov;
+ this.pos = pos;
+ this.center = center;
+ this.axis = axis;
+ this.axis.normalize();
+ move_speed = 0.001;
+ rot_speed = 0.01 * PI;
+ init_pos = pos.copy();
+ init_center = center.copy();
+ init_axis = axis.copy();
+ }
+
+ Camera copy() {
+ Camera cam = new Camera(fov, pos.copy(), center.copy(), axis.copy());
+ return cam;
+ }
+
+ PVector project(PVector pos) {
+ PVector proj = MatxVec3(getCameraMat(), PVector.sub(pos, this.pos));
+ proj.x = (float)height / 2.0 * proj.x / proj.z / tan(fov / 2.0f);
+ proj.y = (float)height / 2.0 * proj.y / proj.z / tan(fov / 2.0f);
+ proj.z = proj.z;
+ return proj;
+ }
+
+ float[] getCameraMat() {
+ float[] mat = new float[9];
+ PVector dir = PVector.sub(center, pos);
+ dir.normalize();
+ PVector left = dir.cross(axis);
+ left.normalize();
+ // processing camera system does not follow right hand rule
+ mat[0] = -left.x;
+ mat[1] = -left.y;
+ mat[2] = -left.z;
+ mat[3] = axis.x;
+ mat[4] = axis.y;
+ mat[5] = axis.z;
+ mat[6] = dir.x;
+ mat[7] = dir.y;
+ mat[8] = dir.z;
+
+ return mat;
+ }
+
+ void run() {
+ PVector dir, left;
+ if (mousePressed) {
+ float angleX = (float)mouseX / width * PI - PI / 2;
+ float angleY = (float)mouseY / height * PI - PI;
+ PVector diff = PVector.sub(center, pos);
+ float radius = diff.mag();
+ pos.x = radius * sin(angleY) * sin(angleX) + center.x;
+ pos.y = radius * cos(angleY) + center.y;
+ pos.z = radius * sin(angleY) * cos(angleX) + center.z;
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ PVector up = new PVector(0, 1, 0);
+ left = up.cross(dir);
+ left.normalize();
+ axis = dir.cross(left);
+ axis.normalize();
+ }
+
+ if (keyPressed) {
+ switch (key) {
+ case 'w':
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ pos = PVector.add(pos, PVector.mult(dir, move_speed));
+ center = PVector.add(center, PVector.mult(dir, move_speed));
+ break;
+ case 's':
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ pos = PVector.sub(pos, PVector.mult(dir, move_speed));
+ center = PVector.sub(center, PVector.mult(dir, move_speed));
+ break;
+ case 'a':
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ left = axis.cross(dir);
+ left.normalize();
+ pos = PVector.add(pos, PVector.mult(left, move_speed));
+ center = PVector.add(center, PVector.mult(left, move_speed));
+ break;
+ case 'd':
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ left = axis.cross(dir);
+ left.normalize();
+ pos = PVector.sub(pos, PVector.mult(left, move_speed));
+ center = PVector.sub(center, PVector.mult(left, move_speed));
+ break;
+ case 'r':
+ dir = PVector.sub(center, pos);
+ dir.normalize();
+ float[] mat = getRotationMat3x3(rot_speed, dir.x, dir.y, dir.z);
+ axis = MatxVec3(mat, axis);
+ axis.normalize();
+ break;
+ case 'b':
+ pos = init_pos.copy();
+ center = init_center.copy();
+ axis = init_axis.copy();
+ break;
+ case '+': move_speed *= 2.0f; break;
+ case '-': move_speed /= 2.0; break;
+ case CODED:
+ if (keyCode == UP) {
+ pos = PVector.add(pos, PVector.mult(axis, move_speed));
+ center = PVector.add(center, PVector.mult(axis, move_speed));
+ } else if (keyCode == DOWN) {
+ pos = PVector.sub(pos, PVector.mult(axis, move_speed));
+ center = PVector.sub(center, PVector.mult(axis, move_speed));
+ }
+ }
+ }
+ }
+ void open() {
+ perspective(fov, float(width) / height, 1e-6, 1e5);
+ camera(pos.x, pos.y, pos.z, center.x, center.y, center.z, axis.x, axis.y,
+ axis.z);
+ }
+ void close() {
+ ortho(-width, 0, -height, 0);
+ camera(0, 0, 0, 0, 0, 1, 0, 1, 0);
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde
new file mode 100644
index 00000000000..a5e04b6a924
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde
@@ -0,0 +1,102 @@
+class MotionField {
+ int block_size;
+ ArrayList<PVector> motion_field;
+ MotionField(int block_size) {
+ this.block_size = block_size;
+ motion_field = new ArrayList<PVector>();
+ }
+
+ void update(Camera last_cam, Camera current_cam, PointCloud point_cloud,
+ BVH bvh) {
+ // clear motion field
+ motion_field = new ArrayList<PVector>();
+ int r_num = height / block_size, c_num = width / block_size;
+ for (int i = 0; i < r_num * c_num; i++)
+ motion_field.add(new PVector(0, 0, 0));
+ // estimate motion vector of each point in point cloud
+ for (int i = 0; i < point_cloud.size(); i++) {
+ PVector p = point_cloud.getPosition(i);
+ PVector p0 = current_cam.project(p);
+ PVector p1 = last_cam.project(p);
+ int row = int((p0.y + height / 2.0f) / block_size);
+ int col = int((p0.x + width / 2.0f) / block_size);
+ if (row >= 0 && row < r_num && col >= 0 && col < c_num) {
+ PVector accu = motion_field.get(row * c_num + col);
+ accu.x += p1.x - p0.x;
+ accu.y += p1.y - p0.y;
+ accu.z += 1;
+ }
+ }
+ // if some blocks do not have point, then use ray tracing to see if they are
+ // in triangles
+ for (int i = 0; i < r_num; i++)
+ for (int j = 0; j < c_num; j++) {
+ PVector accu = motion_field.get(i * c_num + j);
+ if (accu.z > 0) {
+ continue;
+ }
+ // use the center of the block to generate view ray
+ float cx = j * block_size + block_size / 2.0f - width / 2.0f;
+ float cy = i * block_size + block_size / 2.0f - height / 2.0f;
+ float cz = 0.5f * height / tan(current_cam.fov / 2.0f);
+ PVector dir = new PVector(cx, cy, cz);
+ float[] camMat = current_cam.getCameraMat();
+ dir = MatxVec3(transpose3x3(camMat), dir);
+ dir.normalize();
+ Ray r = new Ray(current_cam.pos, dir);
+ // ray tracing
+ float[] param = new float[4];
+ param[0] = Float.POSITIVE_INFINITY;
+ if (bvh.intersect(r, param)) {
+ PVector p = new PVector(param[1], param[2], param[3]);
+ PVector p0 = current_cam.project(p);
+ PVector p1 = last_cam.project(p);
+ accu.x += p1.x - p0.x;
+ accu.y += p1.y - p0.y;
+ accu.z += 1;
+ }
+ }
+ // estimate the motion vector of each block
+ for (int i = 0; i < r_num * c_num; i++) {
+ PVector mv = motion_field.get(i);
+ if (mv.z > 0) {
+ motion_field.set(i, new PVector(mv.x / mv.z, mv.y / mv.z, 0));
+ } else // there is nothing in the block, use -1 to mark it.
+ {
+ motion_field.set(i, new PVector(0.0, 0.0, -1));
+ }
+ }
+ }
+
+ void render() {
+ int r_num = height / block_size, c_num = width / block_size;
+ for (int i = 0; i < r_num; i++)
+ for (int j = 0; j < c_num; j++) {
+ PVector mv = motion_field.get(i * c_num + j);
+ float ox = j * block_size + 0.5f * block_size;
+ float oy = i * block_size + 0.5f * block_size;
+ stroke(255, 0, 0);
+ line(ox, oy, ox + mv.x, oy + mv.y);
+ }
+ }
+
+ void save(String path) {
+ int r_num = height / block_size;
+ int c_num = width / block_size;
+ String[] mvs = new String[r_num];
+ for (int i = 0; i < r_num; i++) {
+ mvs[i] = "";
+ for (int j = 0; j < c_num; j++) {
+ PVector mv = motion_field.get(i * c_num + j);
+ if (mv.z != -1) {
+ mvs[i] += str(mv.x) + "," + str(mv.y);
+ } else // there is nothing
+ {
+ mvs[i] += "-,-";
+ }
+ if (j != c_num - 1) mvs[i] += ";";
+ }
+ }
+ saveStrings(path, mvs);
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde
new file mode 100644
index 00000000000..714a6f3a0b3
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/PointCloud.pde
@@ -0,0 +1,138 @@
+class PointCloud {
+ ArrayList<PVector> points; // array to save points
+ IntList point_colors; // array to save points color
+ PVector cloud_mass;
+ float[] depth;
+ boolean[] real;
+ PointCloud() {
+ // initialize
+ points = new ArrayList<PVector>();
+ point_colors = new IntList();
+ cloud_mass = new PVector(0, 0, 0);
+ depth = new float[width * height];
+ real = new boolean[width * height];
+ }
+
+ void generate(PImage rgb_img, PImage depth_img, Transform trans) {
+ if (depth_img.width != width || depth_img.height != height ||
+ rgb_img.width != width || rgb_img.height != height) {
+ println("rgb and depth file dimension should be same with window size");
+ exit();
+ }
+ // clear depth and real
+ for (int i = 0; i < width * height; i++) {
+ depth[i] = 0;
+ real[i] = false;
+ }
+ for (int v = 0; v < height; v++)
+ for (int u = 0; u < width; u++) {
+ // get depth value (red channel)
+ color depth_px = depth_img.get(u, v);
+ depth[v * width + u] = depth_px & 0x0000FFFF;
+ if (int(depth[v * width + u]) != 0) {
+ real[v * width + u] = true;
+ }
+ point_colors.append(rgb_img.get(u, v));
+ }
+ for (int v = 0; v < height; v++)
+ for (int u = 0; u < width; u++) {
+ if (int(depth[v * width + u]) == 0) {
+ interpolateDepth(v, u);
+ }
+ // add transformed pixel as well as pixel color to the list
+ PVector pos = trans.transform(u, v, int(depth[v * width + u]));
+ points.add(pos);
+ // accumulate z value
+ cloud_mass = PVector.add(cloud_mass, pos);
+ }
+ }
+ void fillInDepthAlongPath(float d, Node node) {
+ node = node.parent;
+ while (node != null) {
+ int i = node.row;
+ int j = node.col;
+ if (depth[i * width + j] == 0) {
+ depth[i * width + j] = d;
+ }
+ node = node.parent;
+ }
+ }
+ // interpolate
+ void interpolateDepth(int row, int col) {
+ if (row < 0 || row >= height || col < 0 || col >= width ||
+ int(depth[row * width + col]) != 0) {
+ return;
+ }
+ ArrayList<Node> queue = new ArrayList<Node>();
+ queue.add(new Node(row, col, null));
+ boolean[] visited = new boolean[width * height];
+ for (int i = 0; i < width * height; i++) visited[i] = false;
+ visited[row * width + col] = true;
+ // Using BFS to Find the Nearest Neighbor
+ while (queue.size() > 0) {
+ // pop
+ Node node = queue.get(0);
+ queue.remove(0);
+ int i = node.row;
+ int j = node.col;
+ // if current position have a real depth
+ if (depth[i * width + j] != 0 && real[i * width + j]) {
+ fillInDepthAlongPath(depth[i * width + j], node);
+ break;
+ } else {
+ // search unvisited 8 neighbors
+ for (int r = max(0, i - 1); r < min(height, i + 2); r++) {
+ for (int c = max(0, j - 1); c < min(width, j + 2); c++) {
+ if (!visited[r * width + c]) {
+ visited[r * width + c] = true;
+ queue.add(new Node(r, c, node));
+ }
+ }
+ }
+ }
+ }
+ }
+ // get point cloud size
+ int size() { return points.size(); }
+ // get ith position
+ PVector getPosition(int i) {
+ if (i >= points.size()) {
+ println("point position: index " + str(i) + " exceeds");
+ exit();
+ }
+ return points.get(i);
+ }
+ // get ith color
+ color getColor(int i) {
+ if (i >= point_colors.size()) {
+ println("point color: index " + str(i) + " exceeds");
+ exit();
+ }
+ return point_colors.get(i);
+ }
+ // get cloud center
+ PVector getCloudCenter() {
+ if (points.size() > 0) {
+ return PVector.div(cloud_mass, points.size());
+ }
+ return new PVector(0, 0, 0);
+ }
+ // merge two clouds
+ void merge(PointCloud point_cloud) {
+ for (int i = 0; i < point_cloud.size(); i++) {
+ points.add(point_cloud.getPosition(i));
+ point_colors.append(point_cloud.getColor(i));
+ }
+ cloud_mass = PVector.add(cloud_mass, point_cloud.cloud_mass);
+ }
+}
+
+class Node {
+ int row, col;
+ Node parent;
+ Node(int row, int col, Node parent) {
+ this.row = row;
+ this.col = col;
+ this.parent = parent;
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde
new file mode 100644
index 00000000000..ef4be691c29
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Ray_Tracing.pde
@@ -0,0 +1,61 @@
+// Triangle
+class Triangle {
+ // position
+ PVector p1, p2, p3;
+ // color
+ color c1, c2, c3;
+ BoundingBox bbx;
+ Triangle(PVector p1, PVector p2, PVector p3, color c1, color c2, color c3) {
+ this.p1 = p1;
+ this.p2 = p2;
+ this.p3 = p3;
+ this.c1 = c1;
+ this.c2 = c2;
+ this.c3 = c3;
+ bbx = new BoundingBox();
+ bbx.create(this);
+ }
+ // check to see if a ray intersects with the triangle
+ boolean intersect(Ray r, float[] param) {
+ PVector p21 = PVector.sub(p2, p1);
+ PVector p31 = PVector.sub(p3, p1);
+ PVector po1 = PVector.sub(r.ori, p1);
+
+ PVector dxp31 = r.dir.cross(p31);
+ PVector po1xp21 = po1.cross(p21);
+ float denom = p21.dot(dxp31);
+ float t = p31.dot(po1xp21) / denom;
+ float alpha = po1.dot(dxp31) / denom;
+ float beta = r.dir.dot(po1xp21) / denom;
+
+ boolean res = t > 0 && alpha > 0 && alpha < 1 && beta > 0 && beta < 1 &&
+ alpha + beta < 1;
+ // depth test
+ if (res && t < param[0]) {
+ param[0] = t;
+ param[1] = alpha * p1.x + beta * p2.x + (1 - alpha - beta) * p3.x;
+ param[2] = alpha * p1.y + beta * p2.y + (1 - alpha - beta) * p3.y;
+ param[3] = alpha * p1.z + beta * p2.z + (1 - alpha - beta) * p3.z;
+ }
+ return res;
+ }
+ void render() {
+ beginShape(TRIANGLES);
+ fill(c1);
+ vertex(p1.x, p1.y, p1.z);
+ fill(c2);
+ vertex(p2.x, p2.y, p2.z);
+ fill(c3);
+ vertex(p3.x, p3.y, p3.z);
+ endShape();
+ }
+}
+// Ray
+class Ray {
+ // origin and direction
+ PVector ori, dir;
+ Ray(PVector ori, PVector dir) {
+ this.ori = ori;
+ this.dir = dir;
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde
new file mode 100644
index 00000000000..cf79ab71418
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde
@@ -0,0 +1,59 @@
+class Scene {
+ PointCloud point_cloud;
+ ArrayList<Triangle> mesh;
+ BVH bvh;
+ MotionField motion_field;
+ Camera last_cam;
+ Camera current_cam;
+ int frame_count;
+
+ Scene(Camera camera, PointCloud point_cloud, MotionField motion_field) {
+ this.point_cloud = point_cloud;
+ this.motion_field = motion_field;
+ mesh = new ArrayList<Triangle>();
+ for (int v = 0; v < height - 1; v++)
+ for (int u = 0; u < width - 1; u++) {
+ PVector p1 = point_cloud.getPosition(v * width + u);
+ PVector p2 = point_cloud.getPosition(v * width + u + 1);
+ PVector p3 = point_cloud.getPosition((v + 1) * width + u + 1);
+ PVector p4 = point_cloud.getPosition((v + 1) * width + u);
+ color c1 = point_cloud.getColor(v * width + u);
+ color c2 = point_cloud.getColor(v * width + u + 1);
+ color c3 = point_cloud.getColor((v + 1) * width + u + 1);
+ color c4 = point_cloud.getColor((v + 1) * width + u);
+ mesh.add(new Triangle(p1, p2, p3, c1, c2, c3));
+ mesh.add(new Triangle(p3, p4, p1, c3, c4, c1));
+ }
+ bvh = new BVH(mesh);
+ last_cam = camera.copy();
+ current_cam = camera;
+ frame_count = 0;
+ }
+
+ void run() {
+ last_cam = current_cam.copy();
+ current_cam.run();
+ motion_field.update(last_cam, current_cam, point_cloud, bvh);
+ frame_count += 1;
+ }
+
+ void render(boolean show_motion_field) {
+ // build mesh
+ current_cam.open();
+ noStroke();
+ for (int i = 0; i < mesh.size(); i++) {
+ Triangle t = mesh.get(i);
+ t.render();
+ }
+ if (show_motion_field) {
+ current_cam.close();
+ motion_field.render();
+ }
+ }
+
+ void save(String path) { saveFrame(path + "_" + str(frame_count) + ".png"); }
+
+ void saveMotionField(String path) {
+ motion_field.save(path + "_" + str(frame_count) + ".txt");
+ }
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde
new file mode 100644
index 00000000000..af2204e8cf2
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Transform.pde
@@ -0,0 +1,82 @@
+class Transform {
+ float[] inv_rot; // inverse of rotation matrix
+ PVector inv_mov; // inverse of movement vector
+ float focal; // the focal distacne of real camera
+ int w, h; // the width and height of the frame
+ float normalier; // nomalization factor of depth
+ Transform(float tx, float ty, float tz, float qx, float qy, float qz,
+ float qw, float fov, int w, int h, float normalier) {
+ // currently, we did not use the info of real camera's position and
+ // quaternion maybe we will use it in the future when combine all frames
+ float[] rot = quaternion2Mat3x3(qx, qy, qz, qw);
+ inv_rot = transpose3x3(rot);
+ inv_mov = new PVector(-tx, -ty, -tz);
+ this.focal = 0.5f * h / tan(fov / 2.0);
+ this.w = w;
+ this.h = h;
+ this.normalier = normalier;
+ }
+
+ PVector transform(int i, int j, float d) {
+ // transfer from camera view to world view
+ float z = d / normalier;
+ float x = (i - w / 2.0f) * z / focal;
+ float y = (j - h / 2.0f) * z / focal;
+ return new PVector(x, y, z);
+ }
+}
+
+// get rotation matrix by using rotation axis and angle
+float[] getRotationMat3x3(float angle, float ax, float ay, float az) {
+ float[] mat = new float[9];
+ float c = cos(angle);
+ float s = sin(angle);
+ mat[0] = c + ax * ax * (1 - c);
+ mat[1] = ax * ay * (1 - c) - az * s;
+ mat[2] = ax * az * (1 - c) + ay * s;
+ mat[3] = ay * ax * (1 - c) + az * s;
+ mat[4] = c + ay * ay * (1 - c);
+ mat[5] = ay * az * (1 - c) - ax * s;
+ mat[6] = az * ax * (1 - c) - ay * s;
+ mat[7] = az * ay * (1 - c) + ax * s;
+ mat[8] = c + az * az * (1 - c);
+ return mat;
+}
+
+// get rotation matrix by using quaternion
+float[] quaternion2Mat3x3(float qx, float qy, float qz, float qw) {
+ float[] mat = new float[9];
+ mat[0] = 1 - 2 * qy * qy - 2 * qz * qz;
+ mat[1] = 2 * qx * qy - 2 * qz * qw;
+ mat[2] = 2 * qx * qz + 2 * qy * qw;
+ mat[3] = 2 * qx * qy + 2 * qz * qw;
+ mat[4] = 1 - 2 * qx * qx - 2 * qz * qz;
+ mat[5] = 2 * qy * qz - 2 * qx * qw;
+ mat[6] = 2 * qx * qz - 2 * qy * qw;
+ mat[7] = 2 * qy * qz + 2 * qx * qw;
+ mat[8] = 1 - 2 * qx * qx - 2 * qy * qy;
+ return mat;
+}
+
+// tranpose a 3x3 matrix
+float[] transpose3x3(float[] mat) {
+ float[] Tmat = new float[9];
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++) {
+ Tmat[i * 3 + j] = mat[j * 3 + i];
+ }
+ return Tmat;
+}
+
+// multiply a matrix with vector
+PVector MatxVec3(float[] mat, PVector v) {
+ float[] vec = v.array();
+ float[] res = new float[3];
+ for (int i = 0; i < 3; i++) {
+ res[i] = 0.0f;
+ for (int j = 0; j < 3; j++) {
+ res[i] += mat[i * 3 + j] * vec[j];
+ }
+ }
+ return new PVector(res[0], res[1], res[2]);
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde
new file mode 100644
index 00000000000..19d124a0b34
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/Util.pde
@@ -0,0 +1,28 @@
+// show grids
+void showGrids(int block_size) {
+ ortho(-width, 0, -height, 0);
+ camera(0, 0, 0, 0, 0, 1, 0, 1, 0);
+ stroke(0, 0, 255);
+ for (int i = 0; i < height; i += block_size) {
+ line(0, i, width, i);
+ }
+ for (int i = 0; i < width; i += block_size) {
+ line(i, 0, i, height);
+ }
+}
+
+// save the point clould information
+void savePointCloud(PointCloud point_cloud, String file_name) {
+ String[] positions = new String[point_cloud.points.size()];
+ String[] colors = new String[point_cloud.points.size()];
+ for (int i = 0; i < point_cloud.points.size(); i++) {
+ PVector point = point_cloud.getPosition(i);
+ color point_color = point_cloud.getColor(i);
+ positions[i] = str(point.x) + ' ' + str(point.y) + ' ' + str(point.z);
+ colors[i] = str(((point_color >> 16) & 0xFF) / 255.0) + ' ' +
+ str(((point_color >> 8) & 0xFF) / 255.0) + ' ' +
+ str((point_color & 0xFF) / 255.0);
+ }
+ saveStrings(file_name + "_pos.txt", positions);
+ saveStrings(file_name + "_color.txt", colors);
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde
new file mode 100644
index 00000000000..22a495432df
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde
@@ -0,0 +1,74 @@
+/*The dataset is from
+ *Computer Vision Group
+ *TUM Department of Informatics Technical
+ *University of Munich
+ *https://vision.in.tum.de/data/datasets/rgbd-dataset/download#freiburg1_xyz
+ */
+Scene scene;
+void setup() {
+ size(640, 480, P3D);
+ // default settings
+ int frame_no = 0; // frame number
+ float fov = PI / 3; // field of view
+ int block_size = 8; // block size
+ float normalizer = 5000.0f; // normalizer
+ // initialize
+ PointCloud point_cloud = new PointCloud();
+ // synchronized rgb, depth and ground truth
+ String head = "../data/";
+ String[] rgb_depth_gt = loadStrings(head + "rgb_depth_groundtruth.txt");
+ // read in rgb and depth image file paths as well as corresponding camera
+ // posiiton and quaternion
+ String[] info = split(rgb_depth_gt[frame_no], ' ');
+ String rgb_path = head + info[1];
+ String depth_path = head + info[3];
+ float tx = float(info[7]), ty = float(info[8]),
+ tz = float(info[9]); // real camera position
+ float qx = float(info[10]), qy = float(info[11]), qz = float(info[12]),
+ qw = float(info[13]); // quaternion
+
+ // build transformer
+ Transform trans =
+ new Transform(tx, ty, tz, qx, qy, qz, qw, fov, width, height, normalizer);
+ PImage rgb = loadImage(rgb_path);
+ PImage depth = loadImage(depth_path);
+ // generate point cloud
+ point_cloud.generate(rgb, depth, trans);
+ // initialize camera
+ Camera camera = new Camera(fov, new PVector(0, 0, 0), new PVector(0, 0, 1),
+ new PVector(0, 1, 0));
+ // initialize motion field
+ MotionField motion_field = new MotionField(block_size);
+ // initialize scene
+ scene = new Scene(camera, point_cloud, motion_field);
+}
+boolean inter = false;
+void draw() {
+ background(0);
+ // run camera dragged mouse to rotate camera
+ // w: go forward
+ // s: go backward
+ // a: go left
+ // d: go right
+ // up arrow: go up
+ // down arrow: go down
+ //+ increase move speed
+ //- decrease move speed
+ // r: rotate the camera
+ // b: reset to initial position
+ scene.run(); // true: make interpolation; false: do not make
+ // interpolation
+ if (keyPressed && key == 'o') {
+ inter = true;
+ }
+ scene.render(
+ false); // true: turn on motion field; false: turn off motion field
+ // save frame with no motion field
+ scene.save("../data/frame/raw");
+ background(0);
+ scene.render(true);
+ showGrids(scene.motion_field.block_size);
+ // save frame with motion field
+ scene.save("../data/frame/raw_mv");
+ scene.saveMotionField("../data/frame/mv");
+}
diff --git a/chromium/third_party/libvpx/source/libvpx/video_writer.c b/chromium/third_party/libvpx/source/libvpx/video_writer.c
index 56d428b0720..6e9a848bc3d 100644
--- a/chromium/third_party/libvpx/source/libvpx/video_writer.c
+++ b/chromium/third_party/libvpx/source/libvpx/video_writer.c
@@ -37,11 +37,15 @@ VpxVideoWriter *vpx_video_writer_open(const char *filename,
if (container == kContainerIVF) {
VpxVideoWriter *writer = NULL;
FILE *const file = fopen(filename, "wb");
- if (!file) return NULL;
-
+ if (!file) {
+ fprintf(stderr, "%s can't be written to.\n", filename);
+ return NULL;
+ }
writer = malloc(sizeof(*writer));
- if (!writer) return NULL;
-
+ if (!writer) {
+ fprintf(stderr, "Can't allocate VpxVideoWriter.\n");
+ return NULL;
+ }
writer->frame_count = 0;
writer->info = *info;
writer->file = file;
@@ -50,7 +54,7 @@ VpxVideoWriter *vpx_video_writer_open(const char *filename,
return writer;
}
-
+ fprintf(stderr, "VpxVideoWriter supports only IVF.\n");
return NULL;
}
diff --git a/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h b/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h
index af812b054a1..50a750da310 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_int.h
@@ -57,6 +57,9 @@ extern "C" {
#define VP8_TEMPORAL_ALT_REF !CONFIG_REALTIME_ONLY
+/* vp8 uses 10,000,000 ticks/second as time stamp */
+#define TICKS_PER_SEC 10000000
+
typedef struct {
int kf_indicated;
unsigned int frames_since_key;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c b/chromium/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c
index d65bf9652e4..eb04f67fa6c 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c
@@ -18,6 +18,7 @@
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/system_state.h"
#include "vpx_ports/vpx_once.h"
+#include "vpx_util/vpx_timestamp.h"
#include "vp8/encoder/onyx_int.h"
#include "vpx/vp8cx.h"
#include "vp8/encoder/firstpass.h"
@@ -75,6 +76,9 @@ struct vpx_codec_alg_priv {
vpx_codec_priv_t base;
vpx_codec_enc_cfg_t cfg;
struct vp8_extracfg vp8_cfg;
+ vpx_rational64_t timestamp_ratio;
+ vpx_codec_pts_t pts_offset;
+ unsigned char pts_offset_initialized;
VP8_CONFIG oxcf;
struct VP8_COMP *cpi;
unsigned char *cx_data;
@@ -127,6 +131,22 @@ static vpx_codec_err_t update_error_state(
if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \
} while (0)
+#if defined(_MSC_VER)
+#define COMPILE_TIME_ASSERT(boolexp) \
+ do { \
+ char compile_time_assert[(boolexp) ? 1 : -1]; \
+ (void)compile_time_assert; \
+ } while (0)
+#else /* !_MSC_VER */
+#define COMPILE_TIME_ASSERT(boolexp) \
+ do { \
+ struct { \
+ unsigned int compile_time_assert : (boolexp) ? 1 : -1; \
+ } compile_time_assert; \
+ (void)compile_time_assert; \
+ } while (0)
+#endif /* _MSC_VER */
+
static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
const vpx_codec_enc_cfg_t *cfg,
const struct vp8_extracfg *vp8_cfg,
@@ -579,7 +599,7 @@ static vpx_codec_err_t set_screen_content_mode(vpx_codec_alg_priv_t *ctx,
static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg,
void **mem_loc) {
- vpx_codec_err_t res = 0;
+ vpx_codec_err_t res = VPX_CODEC_OK;
#if CONFIG_MULTI_RES_ENCODING
LOWER_RES_FRAME_INFO *shared_mem_loc;
@@ -588,12 +608,13 @@ static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg,
shared_mem_loc = calloc(1, sizeof(LOWER_RES_FRAME_INFO));
if (!shared_mem_loc) {
- res = VPX_CODEC_MEM_ERROR;
+ return VPX_CODEC_MEM_ERROR;
}
shared_mem_loc->mb_info =
calloc(mb_rows * mb_cols, sizeof(LOWER_RES_MB_INFO));
if (!(shared_mem_loc->mb_info)) {
+ free(shared_mem_loc);
res = VPX_CODEC_MEM_ERROR;
} else {
*mem_loc = (void *)shared_mem_loc;
@@ -657,6 +678,12 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
res = validate_config(priv, &priv->cfg, &priv->vp8_cfg, 0);
if (!res) {
+ priv->pts_offset_initialized = 0;
+ priv->timestamp_ratio.den = priv->cfg.g_timebase.den;
+ priv->timestamp_ratio.num = (int64_t)priv->cfg.g_timebase.num;
+ priv->timestamp_ratio.num *= TICKS_PER_SEC;
+ reduce_ratio(&priv->timestamp_ratio);
+
set_vp8e_config(&priv->oxcf, priv->cfg, priv->vp8_cfg, mr_cfg);
priv->cpi = vp8_create_compressor(&priv->oxcf);
if (!priv->cpi) res = VPX_CODEC_MEM_ERROR;
@@ -721,12 +748,14 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
new_qc = MODE_BESTQUALITY;
if (deadline) {
+ /* Convert duration parameter from stream timebase to microseconds */
uint64_t duration_us;
- /* Convert duration parameter from stream timebase to microseconds */
- duration_us = (uint64_t)duration * 1000000 *
- (uint64_t)ctx->cfg.g_timebase.num /
- (uint64_t)ctx->cfg.g_timebase.den;
+ COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 &&
+ (TICKS_PER_SEC % 1000000) == 0);
+
+ duration_us = duration * (uint64_t)ctx->timestamp_ratio.num /
+ (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000));
/* If the deadline is more that the duration this frame is to be shown,
* use good quality mode. Otherwise use realtime mode.
@@ -805,6 +834,7 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
volatile vpx_codec_err_t res = VPX_CODEC_OK;
// Make a copy as volatile to avoid -Wclobbered with longjmp.
volatile vpx_enc_frame_flags_t flags = enc_flags;
+ volatile vpx_codec_pts_t pts_val = pts;
if (!ctx->cfg.rc_target_bitrate) {
#if CONFIG_MULTI_RES_ENCODING
@@ -825,6 +855,12 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
if (!res) res = validate_config(ctx, &ctx->cfg, &ctx->vp8_cfg, 1);
+ if (!ctx->pts_offset_initialized) {
+ ctx->pts_offset = pts_val;
+ ctx->pts_offset_initialized = 1;
+ }
+ pts_val -= ctx->pts_offset;
+
pick_quickcompress_mode(ctx, duration, deadline);
vpx_codec_pkt_list_init(&ctx->pkt_list);
@@ -874,11 +910,10 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
/* Convert API flags to internal codec lib flags */
lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
- /* vp8 use 10,000,000 ticks/second as time stamp */
dst_time_stamp =
- pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
- dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num /
- ctx->cfg.g_timebase.den;
+ pts_val * ctx->timestamp_ratio.num / ctx->timestamp_ratio.den;
+ dst_end_time_stamp = (pts_val + duration) * ctx->timestamp_ratio.num /
+ ctx->timestamp_ratio.den;
if (img != NULL) {
res = image2yuvconfig(img, &sd);
@@ -917,15 +952,17 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
/* Add the frame packet to the list of returned packets. */
- round = (vpx_codec_pts_t)10000000 * ctx->cfg.g_timebase.num / 2 - 1;
+ round = (vpx_codec_pts_t)ctx->timestamp_ratio.num / 2;
+ if (round > 0) --round;
delta = (dst_end_time_stamp - dst_time_stamp);
pkt.kind = VPX_CODEC_CX_FRAME_PKT;
pkt.data.frame.pts =
- (dst_time_stamp * ctx->cfg.g_timebase.den + round) /
- ctx->cfg.g_timebase.num / 10000000;
+ (dst_time_stamp * ctx->timestamp_ratio.den + round) /
+ ctx->timestamp_ratio.num +
+ ctx->pts_offset;
pkt.data.frame.duration =
- (unsigned long)((delta * ctx->cfg.g_timebase.den + round) /
- ctx->cfg.g_timebase.num / 10000000);
+ (unsigned long)((delta * ctx->timestamp_ratio.den + round) /
+ ctx->timestamp_ratio.num);
pkt.data.frame.flags = lib_flags << 16;
pkt.data.frame.width[0] = cpi->common.Width;
pkt.data.frame.height[0] = cpi->common.Height;
@@ -944,9 +981,9 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
* Invisible frames have no duration.
*/
pkt.data.frame.pts =
- ((cpi->last_time_stamp_seen * ctx->cfg.g_timebase.den + round) /
- ctx->cfg.g_timebase.num / 10000000) +
- 1;
+ ((cpi->last_time_stamp_seen * ctx->timestamp_ratio.den + round) /
+ ctx->timestamp_ratio.num) +
+ ctx->pts_offset + 1;
pkt.data.frame.duration = 0;
}
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h
index 662b8ef5e12..94c9b3f268f 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_onyxc_int.h
@@ -244,14 +244,6 @@ typedef struct VP9Common {
int byte_alignment;
int skip_loop_filter;
- // Private data associated with the frame buffer callbacks.
- void *cb_priv;
- vpx_get_frame_buffer_cb_fn_t get_fb_cb;
- vpx_release_frame_buffer_cb_fn_t release_fb_cb;
-
- // Handles memory for the codec.
- InternalFrameBufferList int_frame_buffers;
-
// External BufferPool passed from outside.
BufferPool *buffer_pool;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c
index 5373b021812..d2c8535b01c 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.c
@@ -183,7 +183,8 @@ void vp9_highbd_mbpost_proc_down_c(uint16_t *dst, int pitch, int rows, int cols,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
+static void deblock_and_de_macro_block(VP9_COMMON *cm,
+ YV12_BUFFER_CONFIG *source,
YV12_BUFFER_CONFIG *post, int q,
int low_var_thresh, int flag,
uint8_t *limits) {
@@ -216,7 +217,7 @@ static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
source->uv_height, source->uv_width, ppl);
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
- vp9_deblock(source, post, q, limits);
+ vp9_deblock(cm, source, post, q, limits);
vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
post->y_width, q2mbl(q));
vpx_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
@@ -226,8 +227,8 @@ static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
#endif // CONFIG_VP9_HIGHBITDEPTH
}
-void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits) {
+void vp9_deblock(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) {
const int ppl =
(int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q + 0.0065 + 0.5);
#if CONFIG_VP9_HIGHBITDEPTH
@@ -252,9 +253,8 @@ void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
int mbr;
- const int mb_rows = src->y_height / 16;
- const int mb_cols = src->y_width / 16;
-
+ const int mb_rows = cm->mb_rows;
+ const int mb_cols = cm->mb_cols;
memset(limits, (unsigned char)ppl, 16 * mb_cols);
for (mbr = 0; mbr < mb_rows; mbr++) {
@@ -276,9 +276,9 @@ void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
#endif // CONFIG_VP9_HIGHBITDEPTH
}
-void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits) {
- vp9_deblock(src, dst, q, limits);
+void vp9_denoise(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) {
+ vp9_deblock(cm, src, dst, q, limits);
}
static void swap_mi_and_prev_mi(VP9_COMMON *cm) {
@@ -383,21 +383,21 @@ int vp9_post_proc_frame(struct VP9Common *cm, YV12_BUFFER_CONFIG *dest,
vpx_yv12_copy_frame(ppbuf, &cm->post_proc_buffer_int);
}
if ((flags & VP9D_DEMACROBLOCK) && cm->post_proc_buffer_int.buffer_alloc) {
- deblock_and_de_macro_block(&cm->post_proc_buffer_int, ppbuf,
+ deblock_and_de_macro_block(cm, &cm->post_proc_buffer_int, ppbuf,
q + (ppflags->deblocking_level - 5) * 10, 1, 0,
cm->postproc_state.limits);
} else if (flags & VP9D_DEBLOCK) {
- vp9_deblock(&cm->post_proc_buffer_int, ppbuf, q,
+ vp9_deblock(cm, &cm->post_proc_buffer_int, ppbuf, q,
cm->postproc_state.limits);
} else {
vpx_yv12_copy_frame(&cm->post_proc_buffer_int, ppbuf);
}
} else if (flags & VP9D_DEMACROBLOCK) {
- deblock_and_de_macro_block(cm->frame_to_show, ppbuf,
+ deblock_and_de_macro_block(cm, cm->frame_to_show, ppbuf,
q + (ppflags->deblocking_level - 5) * 10, 1, 0,
cm->postproc_state.limits);
} else if (flags & VP9D_DEBLOCK) {
- vp9_deblock(cm->frame_to_show, ppbuf, q, cm->postproc_state.limits);
+ vp9_deblock(cm, cm->frame_to_show, ppbuf, q, cm->postproc_state.limits);
} else {
vpx_yv12_copy_frame(cm->frame_to_show, ppbuf);
}
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h
index 67efc1b4e4b..bbe3aed8353 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/common/vp9_postproc.h
@@ -40,11 +40,11 @@ struct VP9Common;
int vp9_post_proc_frame(struct VP9Common *cm, YV12_BUFFER_CONFIG *dest,
vp9_ppflags_t *ppflags, int unscaled_width);
-void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits);
+void vp9_denoise(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits);
-void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits);
+void vp9_deblock(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits);
#ifdef __cplusplus
} // extern "C"
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c
index e510ee1fd9d..9eddf545eed 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encodeframe.c
@@ -37,11 +37,14 @@
#include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_tile_common.h"
-
+#if !CONFIG_REALTIME_ONLY
#include "vp9/encoder/vp9_aq_360.h"
#include "vp9/encoder/vp9_aq_complexity.h"
+#endif
#include "vp9/encoder/vp9_aq_cyclicrefresh.h"
+#if !CONFIG_REALTIME_ONLY
#include "vp9/encoder/vp9_aq_variance.h"
+#endif
#include "vp9/encoder/vp9_encodeframe.h"
#include "vp9/encoder/vp9_encodemb.h"
#include "vp9/encoder/vp9_encodemv.h"
@@ -156,6 +159,7 @@ 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,
@@ -184,6 +188,7 @@ static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi, MACROBLOCK *x,
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) {
@@ -206,6 +211,7 @@ static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row,
case CYCLIC_REFRESH_AQ:
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
break;
+#if !CONFIG_REALTIME_ONLY
case VARIANCE_AQ:
if (cm->frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame ||
cpi->force_update_segmentation ||
@@ -225,15 +231,16 @@ static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row,
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
}
break;
- case LOOKAHEAD_AQ:
- mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
- break;
case EQUATOR360_AQ:
if (cm->frame_type == KEY_FRAME || cpi->force_update_segmentation)
mi->segment_id = vp9_360aq_segment_id(mi_row, cm->mi_rows);
else
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
break;
+#endif
+ case LOOKAHEAD_AQ:
+ mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
+ break;
case PSNR_AQ: mi->segment_id = segment_index; break;
case PERCEPTUAL_AQ: mi->segment_id = x->segment_id; break;
default:
@@ -261,21 +268,38 @@ static INLINE void set_mode_info_offsets(VP9_COMMON *const cm,
}
static void set_ssim_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x,
- int mi_row, int mi_col, int *rdmult) {
+ const BLOCK_SIZE bsize, const int mi_row,
+ const int mi_col, int *const rdmult) {
const VP9_COMMON *const cm = &cpi->common;
- // SSIM rdmult scaling factors are currently 64x64 based.
- const int num_8x8_w = 8;
- const int num_8x8_h = 8;
+ const int bsize_base = BLOCK_16X16;
+ const int num_8x8_w = num_8x8_blocks_wide_lookup[bsize_base];
+ const int num_8x8_h = num_8x8_blocks_high_lookup[bsize_base];
const int num_cols = (cm->mi_cols + num_8x8_w - 1) / num_8x8_w;
- const int row = mi_row / num_8x8_h;
- const int col = mi_col / num_8x8_w;
- const int index = row * num_cols + col;
+ const int num_rows = (cm->mi_rows + num_8x8_h - 1) / num_8x8_h;
+ const int num_bcols =
+ (num_8x8_blocks_wide_lookup[bsize] + num_8x8_w - 1) / num_8x8_w;
+ const int num_brows =
+ (num_8x8_blocks_high_lookup[bsize] + num_8x8_h - 1) / num_8x8_h;
+ int row, col;
+ double num_of_mi = 0.0;
+ double geom_mean_of_scale = 0.0;
assert(cpi->oxcf.tuning == VP8_TUNE_SSIM);
- *rdmult =
- (int)((double)(*rdmult) * cpi->mi_ssim_rdmult_scaling_factors[index]);
- *rdmult = VPXMAX(*rdmult, 1);
+
+ for (row = mi_row / num_8x8_w;
+ row < num_rows && row < mi_row / num_8x8_w + num_brows; ++row) {
+ for (col = mi_col / num_8x8_h;
+ col < num_cols && col < mi_col / num_8x8_h + num_bcols; ++col) {
+ const int index = row * num_cols + col;
+ geom_mean_of_scale += log(cpi->mi_ssim_rdmult_scaling_factors[index]);
+ num_of_mi += 1.0;
+ }
+ }
+ geom_mean_of_scale = exp(geom_mean_of_scale / num_of_mi);
+
+ *rdmult = (int)((double)(*rdmult) * geom_mean_of_scale);
+ *rdmult = VPXMAX(*rdmult, 0);
set_error_per_bit(x, *rdmult);
vpx_clear_system_state();
}
@@ -316,7 +340,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile,
x->rddiv = cpi->rd.RDDIV;
x->rdmult = cpi->rd.RDMULT;
if (oxcf->tuning == VP8_TUNE_SSIM) {
- set_ssim_rdmult(cpi, x, mi_row, mi_col, &x->rdmult);
+ set_ssim_rdmult(cpi, x, bsize, mi_row, mi_col, &x->rdmult);
}
// required by vp9_append_sub8x8_mvs_for_idx() and vp9_find_best_ref_mvs()
@@ -1190,8 +1214,8 @@ static void chroma_check(VP9_COMP *cpi, MACROBLOCK *x, int bsize,
if (is_key_frame) return;
- // For speed >= 8, avoid the chroma check if y_sad is above threshold.
- if (cpi->oxcf.speed >= 8) {
+ // For speed > 8, avoid the chroma check if y_sad is above threshold.
+ if (cpi->oxcf.speed > 8) {
if (y_sad > cpi->vbp_thresholds[1] &&
(!cpi->noise_estimate.enabled ||
vp9_noise_estimate_extract_level(&cpi->noise_estimate) < kMedium))
@@ -1765,6 +1789,7 @@ static int choose_partitioning(VP9_COMP *cpi, const TileInfo *const tile,
return 0;
}
+#if !CONFIG_REALTIME_ONLY
static void update_state(VP9_COMP *cpi, ThreadData *td, PICK_MODE_CONTEXT *ctx,
int mi_row, int mi_col, BLOCK_SIZE bsize,
int output_enabled) {
@@ -1893,6 +1918,7 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, PICK_MODE_CONTEXT *ctx,
}
}
}
+#endif // !CONFIG_REALTIME_ONLY
void vp9_setup_src_planes(MACROBLOCK *x, const YV12_BUFFER_CONFIG *src,
int mi_row, int mi_col) {
@@ -1935,6 +1961,7 @@ static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode,
vp9_rd_cost_init(rd_cost);
}
+#if !CONFIG_REALTIME_ONLY
static void set_segment_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x,
int mi_row, int mi_col, BLOCK_SIZE bsize,
AQ_MODE aq_mode) {
@@ -1960,14 +1987,15 @@ static void set_segment_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x,
}
if (oxcf->tuning == VP8_TUNE_SSIM) {
- set_ssim_rdmult(cpi, x, mi_row, mi_col, &x->rdmult);
+ set_ssim_rdmult(cpi, x, bsize, mi_row, mi_col, &x->rdmult);
}
}
static void rd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
MACROBLOCK *const x, int mi_row, int mi_col,
RD_COST *rd_cost, BLOCK_SIZE bsize,
- PICK_MODE_CONTEXT *ctx, int64_t best_rd) {
+ PICK_MODE_CONTEXT *ctx, int rate_in_best_rd,
+ int64_t dist_in_best_rd) {
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -1976,6 +2004,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
struct macroblockd_plane *const pd = xd->plane;
const AQ_MODE aq_mode = cpi->oxcf.aq_mode;
int i, orig_rdmult;
+ int64_t best_rd = INT64_MAX;
vpx_clear_system_state();
@@ -2034,6 +2063,10 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
set_segment_index(cpi, x, mi_row, mi_col, bsize, 0);
set_segment_rdmult(cpi, x, mi_row, mi_col, bsize, aq_mode);
+ if (rate_in_best_rd < INT_MAX && dist_in_best_rd < INT64_MAX) {
+ best_rd = vp9_calculate_rd_cost(x->rdmult, x->rddiv, rate_in_best_rd,
+ dist_in_best_rd);
+ }
// Find best coding mode & reconstruct the MB so it is available
// as a predictor for MBs that follow in the SB
@@ -2063,7 +2096,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
// TODO(jingning) The rate-distortion optimization flow needs to be
// refactored to provide proper exit/return handle.
- if (rd_cost->rate == INT_MAX)
+ if (rd_cost->rate == INT_MAX || rd_cost->dist == INT64_MAX)
rd_cost->rdcost = INT64_MAX;
else
rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
@@ -2073,6 +2106,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
ctx->rate = rd_cost->rate;
ctx->dist = rd_cost->dist;
}
+#endif // !CONFIG_REALTIME_ONLY
static void update_stats(VP9_COMMON *cm, ThreadData *td) {
const MACROBLOCK *x = &td->mb;
@@ -2133,6 +2167,7 @@ static void update_stats(VP9_COMMON *cm, ThreadData *td) {
}
}
+#if !CONFIG_REALTIME_ONLY
static void restore_context(MACROBLOCK *const x, int mi_row, int mi_col,
ENTROPY_CONTEXT a[16 * MAX_MB_PLANE],
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE],
@@ -2203,7 +2238,7 @@ static void encode_b(VP9_COMP *cpi, const TileInfo *const tile, ThreadData *td,
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
x->rdmult = x->cb_rdmult;
if (oxcf->tuning == VP8_TUNE_SSIM) {
- set_ssim_rdmult(cpi, x, mi_row, mi_col, &x->rdmult);
+ set_ssim_rdmult(cpi, x, bsize, mi_row, mi_col, &x->rdmult);
}
}
@@ -2286,6 +2321,7 @@ static void encode_sb(VP9_COMP *cpi, ThreadData *td, const TileInfo *const tile,
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
+#endif // !CONFIG_REALTIME_ONLY
// Check to see if the given partition size is allowed for a specified number
// of 8x8 block rows and columns remaining in the image.
@@ -2622,6 +2658,7 @@ static void encode_sb_rt(VP9_COMP *cpi, ThreadData *td,
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
+#if !CONFIG_REALTIME_ONLY
static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
TileDataEnc *tile_data, MODE_INFO **mi_8x8,
TOKENEXTRA **tp, int mi_row, int mi_col,
@@ -2690,7 +2727,7 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
mi_col + (mi_step >> 1) < cm->mi_cols) {
pc_tree->partitioning = PARTITION_NONE;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &none_rdc, bsize, ctx,
- INT64_MAX);
+ INT_MAX, INT64_MAX);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
@@ -2709,12 +2746,12 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
switch (partition) {
case PARTITION_NONE:
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &last_part_rdc, bsize,
- ctx, INT64_MAX);
+ ctx, INT_MAX, INT64_MAX);
break;
case PARTITION_HORZ:
pc_tree->horizontal[0].skip_ref_frame_mask = 0;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &last_part_rdc,
- subsize, &pc_tree->horizontal[0], INT64_MAX);
+ subsize, &pc_tree->horizontal[0], INT_MAX, INT64_MAX);
if (last_part_rdc.rate != INT_MAX && bsize >= BLOCK_8X8 &&
mi_row + (mi_step >> 1) < cm->mi_rows) {
RD_COST tmp_rdc;
@@ -2724,7 +2761,8 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx);
pc_tree->horizontal[1].skip_ref_frame_mask = 0;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + (mi_step >> 1), mi_col,
- &tmp_rdc, subsize, &pc_tree->horizontal[1], INT64_MAX);
+ &tmp_rdc, subsize, &pc_tree->horizontal[1], INT_MAX,
+ INT64_MAX);
if (tmp_rdc.rate == INT_MAX || tmp_rdc.dist == INT64_MAX) {
vp9_rd_cost_reset(&last_part_rdc);
break;
@@ -2737,7 +2775,7 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
case PARTITION_VERT:
pc_tree->vertical[0].skip_ref_frame_mask = 0;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &last_part_rdc,
- subsize, &pc_tree->vertical[0], INT64_MAX);
+ subsize, &pc_tree->vertical[0], INT_MAX, INT64_MAX);
if (last_part_rdc.rate != INT_MAX && bsize >= BLOCK_8X8 &&
mi_col + (mi_step >> 1) < cm->mi_cols) {
RD_COST tmp_rdc;
@@ -2746,9 +2784,9 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0);
encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx);
pc_tree->vertical[bsize > BLOCK_8X8].skip_ref_frame_mask = 0;
- rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + (mi_step >> 1),
- &tmp_rdc, subsize,
- &pc_tree->vertical[bsize > BLOCK_8X8], INT64_MAX);
+ rd_pick_sb_modes(
+ cpi, tile_data, x, mi_row, mi_col + (mi_step >> 1), &tmp_rdc,
+ subsize, &pc_tree->vertical[bsize > BLOCK_8X8], INT_MAX, INT64_MAX);
if (tmp_rdc.rate == INT_MAX || tmp_rdc.dist == INT64_MAX) {
vp9_rd_cost_reset(&last_part_rdc);
break;
@@ -2762,7 +2800,7 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
assert(partition == PARTITION_SPLIT);
if (bsize == BLOCK_8X8) {
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &last_part_rdc,
- subsize, pc_tree->leaf_split[0], INT64_MAX);
+ subsize, pc_tree->leaf_split[0], INT_MAX, INT64_MAX);
break;
}
last_part_rdc.rate = 0;
@@ -2826,7 +2864,7 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
pc_tree->split[i]->partitioning = PARTITION_NONE;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + y_idx, mi_col + x_idx,
&tmp_rdc, split_subsize, &pc_tree->split[i]->none,
- INT64_MAX);
+ INT_MAX, INT64_MAX);
restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3060,6 +3098,7 @@ static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, int mi_row,
*min_bs = min_size;
*max_bs = max_size;
}
+#endif // !CONFIG_REALTIME_ONLY
static INLINE void store_pred_mv(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) {
memcpy(ctx->pred_mv, x->pred_mv, sizeof(x->pred_mv));
@@ -3164,6 +3203,7 @@ static void nn_predict(const float *features, const NN_CONFIG *nn_config,
}
}
+#if !CONFIG_REALTIME_ONLY
#define FEATURES 7
// Machine-learning based partition search early termination.
// Return 1 to skip split and rect partitions.
@@ -3613,6 +3653,7 @@ static void ml_predict_var_rd_paritioning(const VP9_COMP *const cpi,
}
}
#undef FEATURES
+#endif // !CONFIG_REALTIME_ONLY
static double log_wiener_var(int64_t wiener_variance) {
return log(1.0 + wiener_variance) / log(2.0);
@@ -3668,6 +3709,7 @@ static void build_kmeans_segmentation(VP9_COMP *cpi) {
}
}
+#if !CONFIG_REALTIME_ONLY
static int wiener_var_segment(VP9_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
int mi_col) {
VP9_COMMON *cm = &cpi->common;
@@ -3759,15 +3801,17 @@ static int get_rdmult_delta(VP9_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
return dr;
}
+#endif // !CONFIG_REALTIME_ONLY
+#if !CONFIG_REALTIME_ONLY
// TODO(jingning,jimbankoski,rbultje): properly skip partition types that are
// unlikely to be selected depending on previous rate-distortion optimization
// results, for encoding speed-up.
-static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
- TileDataEnc *tile_data, TOKENEXTRA **tp,
- int mi_row, int mi_col, BLOCK_SIZE bsize,
- RD_COST *rd_cost, int64_t best_rd,
- PC_TREE *pc_tree) {
+static int rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
+ TileDataEnc *tile_data, TOKENEXTRA **tp,
+ int mi_row, int mi_col, BLOCK_SIZE bsize,
+ RD_COST *rd_cost, RD_COST best_rdc,
+ PC_TREE *pc_tree) {
VP9_COMMON *const cm = &cpi->common;
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
TileInfo *const tile_info = &tile_data->tile_info;
@@ -3781,7 +3825,7 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
int i;
const int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
BLOCK_SIZE subsize;
- RD_COST this_rdc, sum_rdc, best_rdc;
+ RD_COST this_rdc, sum_rdc;
int do_split = bsize >= BLOCK_8X8;
int do_rect = 1;
INTERP_FILTER pred_interp_filter;
@@ -3809,15 +3853,13 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
int64_t dist_breakout_thr = cpi->sf.partition_search_breakout_thr.dist;
int rate_breakout_thr = cpi->sf.partition_search_breakout_thr.rate;
int must_split = 0;
+ int should_encode_sb = 0;
// Ref frames picked in the [i_th] quarter subblock during square partition
// RD search. It may be used to prune ref frame selection of rect partitions.
uint8_t ref_frames_used[4] = { 0, 0, 0, 0 };
int partition_mul = x->cb_rdmult;
- if (oxcf->tuning == VP8_TUNE_SSIM) {
- set_ssim_rdmult(cpi, x, mi_row, mi_col, &partition_mul);
- }
(void)*tp_orig;
@@ -3831,11 +3873,14 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
vp9_rd_cost_init(&this_rdc);
vp9_rd_cost_init(&sum_rdc);
- vp9_rd_cost_reset(&best_rdc);
- best_rdc.rdcost = best_rd;
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
+ if (oxcf->tuning == VP8_TUNE_SSIM) {
+ set_ssim_rdmult(cpi, x, bsize, mi_row, mi_col, &partition_mul);
+ }
+ vp9_rd_cost_update(partition_mul, x->rddiv, &best_rdc);
+
if (bsize == BLOCK_16X16 && cpi->oxcf.aq_mode != NO_AQ &&
cpi->oxcf.aq_mode != LOOKAHEAD_AQ)
x->mb_energy = vp9_block_energy(cpi, x, bsize);
@@ -3965,7 +4010,7 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
// PARTITION_NONE
if (partition_none_allowed) {
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &this_rdc, bsize, ctx,
- best_rdc.rdcost);
+ best_rdc.rate, best_rdc.dist);
ctx->rdcost = this_rdc.rdcost;
if (this_rdc.rate != INT_MAX) {
if (cpi->sf.prune_ref_frame_for_rect_partitions) {
@@ -3977,15 +4022,15 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
}
}
if (bsize >= BLOCK_8X8) {
- this_rdc.rdcost += RDCOST(partition_mul, x->rddiv,
- cpi->partition_cost[pl][PARTITION_NONE], 0);
this_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
+ vp9_rd_cost_update(partition_mul, x->rddiv, &this_rdc);
}
if (this_rdc.rdcost < best_rdc.rdcost) {
MODE_INFO *mi = xd->mi[0];
best_rdc = this_rdc;
+ should_encode_sb = 1;
if (bsize >= BLOCK_8X8) pc_tree->partitioning = PARTITION_NONE;
if (cpi->sf.rd_ml_partition.search_early_termination) {
@@ -4102,7 +4147,7 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
if (cpi->sf.adaptive_pred_interp_filter && partition_none_allowed)
pc_tree->leaf_split[0]->pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
- pc_tree->leaf_split[0], best_rdc.rdcost);
+ pc_tree->leaf_split[0], best_rdc.rate, best_rdc.dist);
if (sum_rdc.rate == INT_MAX) {
sum_rdc.rdcost = INT64_MAX;
} else {
@@ -4120,6 +4165,23 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
++i) {
const int x_idx = (i & 1) * mi_step;
const int y_idx = (i >> 1) * mi_step;
+ int found_best_rd = 0;
+ RD_COST best_rdc_split;
+ vp9_rd_cost_reset(&best_rdc_split);
+
+ if (best_rdc.rate < INT_MAX && best_rdc.dist < INT64_MAX) {
+ // A must split test here increases the number of sub
+ // partitions but hurts metrics results quite a bit,
+ // so this extra test is commented out pending
+ // further tests on whether it adds much in terms of
+ // visual quality.
+ // (must_split) ? best_rdc.rate
+ // : best_rdc.rate - sum_rdc.rate,
+ // (must_split) ? best_rdc.dist
+ // : best_rdc.dist - sum_rdc.dist,
+ best_rdc_split.rate = best_rdc.rate - sum_rdc.rate;
+ best_rdc_split.dist = best_rdc.dist - sum_rdc.dist;
+ }
if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols)
continue;
@@ -4127,18 +4189,11 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
pc_tree->split[i]->index = i;
if (cpi->sf.prune_ref_frame_for_rect_partitions)
pc_tree->split[i]->none.rate = INT_MAX;
- rd_pick_partition(cpi, td, tile_data, tp, mi_row + y_idx,
- mi_col + x_idx, subsize, &this_rdc,
- // A must split test here increases the number of sub
- // partitions but hurts metrics results quite a bit,
- // so this extra test is commented out pending
- // further tests on whether it adds much in terms of
- // visual quality.
- // (must_split) ? best_rdc.rdcost
- // : best_rdc.rdcost - sum_rdc.rdcost,
- best_rdc.rdcost - sum_rdc.rdcost, pc_tree->split[i]);
-
- if (this_rdc.rate == INT_MAX) {
+ found_best_rd = rd_pick_partition(
+ cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
+ &this_rdc, best_rdc_split, pc_tree->split[i]);
+
+ if (found_best_rd == 0) {
sum_rdc.rdcost = INT64_MAX;
break;
} else {
@@ -4151,19 +4206,19 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
}
sum_rdc.rate += this_rdc.rate;
sum_rdc.dist += this_rdc.dist;
- sum_rdc.rdcost += this_rdc.rdcost;
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
}
}
}
if (((sum_rdc.rdcost < best_rdc.rdcost) || must_split) && i == 4) {
- sum_rdc.rdcost += RDCOST(partition_mul, x->rddiv,
- cpi->partition_cost[pl][PARTITION_SPLIT], 0);
sum_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
if ((sum_rdc.rdcost < best_rdc.rdcost) ||
(must_split && (sum_rdc.dist < best_rdc.dist))) {
best_rdc = sum_rdc;
+ should_encode_sb = 1;
pc_tree->partitioning = PARTITION_SPLIT;
// Rate and distortion based partition search termination clause.
@@ -4193,13 +4248,21 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
if (cpi->sf.prune_ref_frame_for_rect_partitions) {
uint8_t used_frames;
used_frames = ref_frames_used[0] | ref_frames_used[1];
- if (used_frames) pc_tree->horizontal[0].skip_ref_frame_mask = ~used_frames;
+ if (used_frames) {
+ pc_tree->horizontal[0].skip_ref_frame_mask = ~used_frames & 0xff;
+ }
used_frames = ref_frames_used[2] | ref_frames_used[3];
- if (used_frames) pc_tree->horizontal[1].skip_ref_frame_mask = ~used_frames;
+ if (used_frames) {
+ pc_tree->horizontal[1].skip_ref_frame_mask = ~used_frames & 0xff;
+ }
used_frames = ref_frames_used[0] | ref_frames_used[2];
- if (used_frames) pc_tree->vertical[0].skip_ref_frame_mask = ~used_frames;
+ if (used_frames) {
+ pc_tree->vertical[0].skip_ref_frame_mask = ~used_frames & 0xff;
+ }
used_frames = ref_frames_used[1] | ref_frames_used[3];
- if (used_frames) pc_tree->vertical[1].skip_ref_frame_mask = ~used_frames;
+ if (used_frames) {
+ pc_tree->vertical[1].skip_ref_frame_mask = ~used_frames & 0xff;
+ }
}
{
@@ -4216,19 +4279,17 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
if (partition_horz_allowed &&
(do_rect || vp9_active_h_edge(cpi, mi_row, mi_step))) {
const int part_mode_rate = cpi->partition_cost[pl][PARTITION_HORZ];
- const int64_t part_mode_rdcost =
- RDCOST(partition_mul, x->rddiv, part_mode_rate, 0);
subsize = get_subsize(bsize, PARTITION_HORZ);
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->horizontal[0].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
- &pc_tree->horizontal[0],
- best_rdc.rdcost - part_mode_rdcost);
+ &pc_tree->horizontal[0], best_rdc.rate - part_mode_rate,
+ best_rdc.dist);
if (sum_rdc.rdcost < INT64_MAX) {
- sum_rdc.rdcost += part_mode_rdcost;
sum_rdc.rate += part_mode_rate;
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
}
if (sum_rdc.rdcost < best_rdc.rdcost && mi_row + mi_step < cm->mi_rows &&
@@ -4241,18 +4302,20 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
pc_tree->horizontal[1].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col, &this_rdc,
subsize, &pc_tree->horizontal[1],
- best_rdc.rdcost - sum_rdc.rdcost);
+ best_rdc.rate - sum_rdc.rate,
+ best_rdc.dist - sum_rdc.dist);
if (this_rdc.rate == INT_MAX) {
sum_rdc.rdcost = INT64_MAX;
} else {
sum_rdc.rate += this_rdc.rate;
sum_rdc.dist += this_rdc.dist;
- sum_rdc.rdcost += this_rdc.rdcost;
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
}
}
if (sum_rdc.rdcost < best_rdc.rdcost) {
best_rdc = sum_rdc;
+ should_encode_sb = 1;
pc_tree->partitioning = PARTITION_HORZ;
if (cpi->sf.less_rectangular_check &&
@@ -4266,18 +4329,17 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
if (partition_vert_allowed &&
(do_rect || vp9_active_v_edge(cpi, mi_col, mi_step))) {
const int part_mode_rate = cpi->partition_cost[pl][PARTITION_VERT];
- const int64_t part_mode_rdcost =
- RDCOST(partition_mul, x->rddiv, part_mode_rate, 0);
subsize = get_subsize(bsize, PARTITION_VERT);
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->vertical[0].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
- &pc_tree->vertical[0], best_rdc.rdcost - part_mode_rdcost);
+ &pc_tree->vertical[0], best_rdc.rate - part_mode_rate,
+ best_rdc.dist);
if (sum_rdc.rdcost < INT64_MAX) {
- sum_rdc.rdcost += part_mode_rdcost;
sum_rdc.rate += part_mode_rate;
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
}
if (sum_rdc.rdcost < best_rdc.rdcost && mi_col + mi_step < cm->mi_cols &&
@@ -4290,32 +4352,28 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
pc_tree->vertical[1].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step, &this_rdc,
subsize, &pc_tree->vertical[1],
- best_rdc.rdcost - sum_rdc.rdcost);
+ best_rdc.rate - sum_rdc.rate,
+ best_rdc.dist - sum_rdc.dist);
if (this_rdc.rate == INT_MAX) {
sum_rdc.rdcost = INT64_MAX;
} else {
sum_rdc.rate += this_rdc.rate;
sum_rdc.dist += this_rdc.dist;
- sum_rdc.rdcost += this_rdc.rdcost;
+ vp9_rd_cost_update(partition_mul, x->rddiv, &sum_rdc);
}
}
if (sum_rdc.rdcost < best_rdc.rdcost) {
best_rdc = sum_rdc;
+ should_encode_sb = 1;
pc_tree->partitioning = PARTITION_VERT;
}
restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
}
- // TODO(jbb): This code added so that we avoid static analysis
- // warning related to the fact that best_rd isn't used after this
- // point. This code should be refactored so that the duplicate
- // checks occur in some sub function and thus are used...
- (void)best_rd;
*rd_cost = best_rdc;
- if (best_rdc.rate < INT_MAX && best_rdc.dist < INT64_MAX &&
- pc_tree->index != 3) {
+ if (should_encode_sb && pc_tree->index != 3) {
int output_enabled = (bsize == BLOCK_64X64);
encode_sb(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, bsize,
pc_tree);
@@ -4328,6 +4386,8 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
} else {
assert(tp_orig == *tp);
}
+
+ return should_encode_sb;
}
static void encode_rd_sb_row(VP9_COMP *cpi, ThreadData *td,
@@ -4364,6 +4424,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, ThreadData *td,
const int idx_str = cm->mi_stride * mi_row + mi_col;
MODE_INFO **mi = cm->mi_grid_visible + idx_str;
+ vp9_rd_cost_reset(&dummy_rdc);
(*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, sb_row,
sb_col_in_tile);
@@ -4435,12 +4496,13 @@ static void encode_rd_sb_row(VP9_COMP *cpi, ThreadData *td,
}
td->pc_root->none.rdcost = 0;
rd_pick_partition(cpi, td, tile_data, tp, mi_row, mi_col, BLOCK_64X64,
- &dummy_rdc, INT64_MAX, td->pc_root);
+ &dummy_rdc, dummy_rdc, td->pc_root);
}
(*(cpi->row_mt_sync_write_ptr))(&tile_data->row_mt_sync, sb_row,
sb_col_in_tile, num_sb_cols);
}
}
+#endif // !CONFIG_REALTIME_ONLY
static void init_encode_frame_mb_context(VP9_COMP *cpi) {
MACROBLOCK *const x = &cpi->td.mb;
@@ -5731,8 +5793,10 @@ void vp9_encode_sb_row(VP9_COMP *cpi, ThreadData *td, int tile_row,
if (cpi->sf.use_nonrd_pick_mode)
encode_nonrd_sb_row(cpi, td, this_tile, mi_row, &tok);
+#if !CONFIG_REALTIME_ONLY
else
encode_rd_sb_row(cpi, td, this_tile, mi_row, &tok);
+#endif
cpi->tplist[tile_row][tile_col][tile_sb_row].stop = tok;
cpi->tplist[tile_row][tile_col][tile_sb_row].count =
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c
index fde91fadcbe..08d6d4d2ef7 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.c
@@ -44,11 +44,15 @@
#include "vp9/common/vp9_tile_common.h"
#include "vp9/common/vp9_scan.h"
+#if !CONFIG_REALTIME_ONLY
#include "vp9/encoder/vp9_alt_ref_aq.h"
#include "vp9/encoder/vp9_aq_360.h"
#include "vp9/encoder/vp9_aq_complexity.h"
+#endif
#include "vp9/encoder/vp9_aq_cyclicrefresh.h"
+#if !CONFIG_REALTIME_ONLY
#include "vp9/encoder/vp9_aq_variance.h"
+#endif
#include "vp9/encoder/vp9_bitstream.h"
#if CONFIG_INTERNAL_STATS
#include "vp9/encoder/vp9_blockiness.h"
@@ -127,6 +131,7 @@ void highbd_wht_fwd_txfm(int16_t *src_diff, int bw, tran_low_t *coeff,
void wht_fwd_txfm(int16_t *src_diff, int bw, tran_low_t *coeff,
TX_SIZE tx_size);
+#if !CONFIG_REALTIME_ONLY
// compute adaptive threshold for skip recoding
static int compute_context_model_thresh(const VP9_COMP *const cpi) {
const VP9_COMMON *const cm = &cpi->common;
@@ -451,6 +456,7 @@ static int compute_context_model_diff(const VP9_COMMON *const cm) {
return -diff;
}
+#endif // !CONFIG_REALTIME_ONLY
// Test for whether to calculate metrics for the frame.
static int is_psnr_calc_enabled(VP9_COMP *cpi) {
@@ -816,8 +822,28 @@ static void setup_frame(VP9_COMP *cpi) {
// layer ARF case as well.
if (cpi->multi_layer_arf && !cpi->use_svc) {
GF_GROUP *const gf_group = &cpi->twopass.gf_group;
- cm->frame_context_idx = clamp(gf_group->layer_depth[gf_group->index] - 1, 0,
- FRAME_CONTEXTS - 1);
+ const int gf_group_index = gf_group->index;
+ const int boost_frame =
+ !cpi->rc.is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame);
+
+ // frame_context_idx Frame Type
+ // 0 Intra only frame, base layer ARF
+ // 1 ARFs with layer depth = 2,3
+ // 2 ARFs with layer depth > 3
+ // 3 Non-boosted frames
+ if (frame_is_intra_only(cm)) {
+ cm->frame_context_idx = 0;
+ } else if (boost_frame) {
+ if (gf_group->rf_level[gf_group_index] == GF_ARF_STD)
+ cm->frame_context_idx = 0;
+ else if (gf_group->layer_depth[gf_group_index] <= 3)
+ cm->frame_context_idx = 1;
+ else
+ cm->frame_context_idx = 2;
+ } else {
+ cm->frame_context_idx = 3;
+ }
}
if (cm->frame_type == KEY_FRAME) {
@@ -1507,13 +1533,15 @@ static void set_rc_buffer_sizes(RATE_CONTROL *rc,
}
#if CONFIG_VP9_HIGHBITDEPTH
+// TODO(angiebird): make sdx8f available for highbitdepth if needed
#define HIGHBD_BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX4DF) \
cpi->fn_ptr[BT].sdf = SDF; \
cpi->fn_ptr[BT].sdaf = SDAF; \
cpi->fn_ptr[BT].vf = VF; \
cpi->fn_ptr[BT].svf = SVF; \
cpi->fn_ptr[BT].svaf = SVAF; \
- cpi->fn_ptr[BT].sdx4df = SDX4DF;
+ cpi->fn_ptr[BT].sdx4df = SDX4DF; \
+ cpi->fn_ptr[BT].sdx8f = NULL;
#define MAKE_BFP_SAD_WRAPPER(fnname) \
static unsigned int fnname##_bits8(const uint8_t *src_ptr, \
@@ -2180,7 +2208,9 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
cm, cpi->skin_map,
vpx_calloc(cm->mi_rows * cm->mi_cols, sizeof(cpi->skin_map[0])));
+#if !CONFIG_REALTIME_ONLY
CHECK_MEM_ERROR(cm, cpi->alt_ref_aq, vp9_alt_ref_aq_create());
+#endif
CHECK_MEM_ERROR(
cm, cpi->consec_zero_mv,
@@ -2389,7 +2419,7 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
vp9_set_speed_features_framesize_dependent(cpi, oxcf->speed);
{
- const int bsize = BLOCK_64X64;
+ const int bsize = BLOCK_16X16;
const int w = num_8x8_blocks_wide_lookup[bsize];
const int h = num_8x8_blocks_high_lookup[bsize];
const int num_cols = (cm->mi_cols + w - 1) / w;
@@ -2410,62 +2440,67 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
CHECK_MEM_ERROR(cm, cpi->source_diff_var, vpx_calloc(cm->MBs, sizeof(diff)));
cpi->source_var_thresh = 0;
cpi->frames_till_next_var_check = 0;
+#define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX4DF, SDX8F) \
+ cpi->fn_ptr[BT].sdf = SDF; \
+ cpi->fn_ptr[BT].sdaf = SDAF; \
+ cpi->fn_ptr[BT].vf = VF; \
+ cpi->fn_ptr[BT].svf = SVF; \
+ cpi->fn_ptr[BT].svaf = SVAF; \
+ cpi->fn_ptr[BT].sdx4df = SDX4DF; \
+ cpi->fn_ptr[BT].sdx8f = SDX8F;
-#define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX4DF) \
- cpi->fn_ptr[BT].sdf = SDF; \
- cpi->fn_ptr[BT].sdaf = SDAF; \
- cpi->fn_ptr[BT].vf = VF; \
- cpi->fn_ptr[BT].svf = SVF; \
- cpi->fn_ptr[BT].svaf = SVAF; \
- cpi->fn_ptr[BT].sdx4df = SDX4DF;
-
+ // TODO(angiebird): make sdx8f available for every block size
BFP(BLOCK_32X16, vpx_sad32x16, vpx_sad32x16_avg, vpx_variance32x16,
vpx_sub_pixel_variance32x16, vpx_sub_pixel_avg_variance32x16,
- vpx_sad32x16x4d)
+ vpx_sad32x16x4d, NULL)
BFP(BLOCK_16X32, vpx_sad16x32, vpx_sad16x32_avg, vpx_variance16x32,
vpx_sub_pixel_variance16x32, vpx_sub_pixel_avg_variance16x32,
- vpx_sad16x32x4d)
+ vpx_sad16x32x4d, NULL)
BFP(BLOCK_64X32, vpx_sad64x32, vpx_sad64x32_avg, vpx_variance64x32,
vpx_sub_pixel_variance64x32, vpx_sub_pixel_avg_variance64x32,
- vpx_sad64x32x4d)
+ vpx_sad64x32x4d, NULL)
BFP(BLOCK_32X64, vpx_sad32x64, vpx_sad32x64_avg, vpx_variance32x64,
vpx_sub_pixel_variance32x64, vpx_sub_pixel_avg_variance32x64,
- vpx_sad32x64x4d)
+ vpx_sad32x64x4d, NULL)
BFP(BLOCK_32X32, vpx_sad32x32, vpx_sad32x32_avg, vpx_variance32x32,
vpx_sub_pixel_variance32x32, vpx_sub_pixel_avg_variance32x32,
- vpx_sad32x32x4d)
+ vpx_sad32x32x4d, vpx_sad32x32x8)
BFP(BLOCK_64X64, vpx_sad64x64, vpx_sad64x64_avg, vpx_variance64x64,
vpx_sub_pixel_variance64x64, vpx_sub_pixel_avg_variance64x64,
- vpx_sad64x64x4d)
+ vpx_sad64x64x4d, NULL)
BFP(BLOCK_16X16, vpx_sad16x16, vpx_sad16x16_avg, vpx_variance16x16,
vpx_sub_pixel_variance16x16, vpx_sub_pixel_avg_variance16x16,
- vpx_sad16x16x4d)
+ vpx_sad16x16x4d, vpx_sad16x16x8)
BFP(BLOCK_16X8, vpx_sad16x8, vpx_sad16x8_avg, vpx_variance16x8,
vpx_sub_pixel_variance16x8, vpx_sub_pixel_avg_variance16x8,
- vpx_sad16x8x4d)
+ vpx_sad16x8x4d, vpx_sad16x8x8)
BFP(BLOCK_8X16, vpx_sad8x16, vpx_sad8x16_avg, vpx_variance8x16,
vpx_sub_pixel_variance8x16, vpx_sub_pixel_avg_variance8x16,
- vpx_sad8x16x4d)
+ vpx_sad8x16x4d, vpx_sad8x16x8)
BFP(BLOCK_8X8, vpx_sad8x8, vpx_sad8x8_avg, vpx_variance8x8,
- vpx_sub_pixel_variance8x8, vpx_sub_pixel_avg_variance8x8, vpx_sad8x8x4d)
+ vpx_sub_pixel_variance8x8, vpx_sub_pixel_avg_variance8x8, vpx_sad8x8x4d,
+ vpx_sad8x8x8)
BFP(BLOCK_8X4, vpx_sad8x4, vpx_sad8x4_avg, vpx_variance8x4,
- vpx_sub_pixel_variance8x4, vpx_sub_pixel_avg_variance8x4, vpx_sad8x4x4d)
+ vpx_sub_pixel_variance8x4, vpx_sub_pixel_avg_variance8x4, vpx_sad8x4x4d,
+ NULL)
BFP(BLOCK_4X8, vpx_sad4x8, vpx_sad4x8_avg, vpx_variance4x8,
- vpx_sub_pixel_variance4x8, vpx_sub_pixel_avg_variance4x8, vpx_sad4x8x4d)
+ vpx_sub_pixel_variance4x8, vpx_sub_pixel_avg_variance4x8, vpx_sad4x8x4d,
+ NULL)
BFP(BLOCK_4X4, vpx_sad4x4, vpx_sad4x4_avg, vpx_variance4x4,
- vpx_sub_pixel_variance4x4, vpx_sub_pixel_avg_variance4x4, vpx_sad4x4x4d)
+ vpx_sub_pixel_variance4x4, vpx_sub_pixel_avg_variance4x4, vpx_sad4x4x4d,
+ vpx_sad4x4x8)
#if CONFIG_VP9_HIGHBITDEPTH
highbd_set_var_fns(cpi);
@@ -2655,7 +2690,9 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
vp9_bitstream_encode_tiles_buffer_dealloc(cpi);
}
+#if !CONFIG_REALTIME_ONLY
vp9_alt_ref_aq_destroy(cpi->alt_ref_aq);
+#endif
dealloc_compressor_data(cpi);
@@ -2942,6 +2979,7 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
+#if !CONFIG_REALTIME_ONLY
static int scale_down(VP9_COMP *cpi, int q) {
RATE_CONTROL *const rc = &cpi->rc;
GF_GROUP *const gf_group = &cpi->twopass.gf_group;
@@ -3045,14 +3083,19 @@ static int recode_loop_test(VP9_COMP *cpi, int high_limit, int low_limit, int q,
}
return force_recode;
}
+#endif // !CONFIG_REALTIME_ONLY
static void update_ref_frames(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
BufferPool *const pool = cm->buffer_pool;
GF_GROUP *const gf_group = &cpi->twopass.gf_group;
- // Pop ARF.
- if (cm->show_existing_frame) {
+ if (cpi->rc.show_arf_as_gld) {
+ int tmp = cpi->alt_fb_idx;
+ cpi->alt_fb_idx = cpi->gld_fb_idx;
+ cpi->gld_fb_idx = tmp;
+ } else if (cm->show_existing_frame) {
+ // Pop ARF.
cpi->lst_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx =
stack_pop(gf_group->arf_index_stack, gf_group->stack_size);
@@ -3556,7 +3599,8 @@ static void set_size_dependent_vars(VP9_COMP *cpi, int *q, int *bottom_index,
vpx_calloc(cpi->un_scaled_source->y_width,
sizeof(*cpi->common.postproc_state.limits));
}
- vp9_denoise(cpi->Source, cpi->Source, l, cpi->common.postproc_state.limits);
+ vp9_denoise(&cpi->common, cpi->Source, cpi->Source, l,
+ cpi->common.postproc_state.limits);
}
#endif // CONFIG_VP9_POSTPROC
}
@@ -3972,6 +4016,7 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
}
}
+#if !CONFIG_REALTIME_ONLY
// Variance adaptive and in frame q adjustment experiments are mutually
// exclusive.
if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
@@ -3980,15 +4025,20 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
vp9_360aq_frame_setup(cpi);
} else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) {
vp9_setup_in_frame_q_adj(cpi);
- } else if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
- vp9_cyclic_refresh_setup(cpi);
} else if (cpi->oxcf.aq_mode == LOOKAHEAD_AQ) {
// it may be pretty bad for rate-control,
// and I should handle it somehow
vp9_alt_ref_aq_setup_map(cpi->alt_ref_aq, cpi);
- } else if (cpi->roi.enabled && !frame_is_intra_only(cm)) {
- apply_roi_map(cpi);
+ } else {
+#endif
+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
+ vp9_cyclic_refresh_setup(cpi);
+ } else if (cpi->roi.enabled && !frame_is_intra_only(cm)) {
+ apply_roi_map(cpi);
+ }
+#if !CONFIG_REALTIME_ONLY
}
+#endif
apply_active_map(cpi);
@@ -4041,6 +4091,7 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
return 1;
}
+#if !CONFIG_REALTIME_ONLY
#define MAX_QSTEP_ADJ 4
static int get_qstep_adj(int rate_excess, int rate_limit) {
int qstep =
@@ -4403,6 +4454,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
restore_coding_context(cpi);
}
}
+#endif // !CONFIG_REALTIME_ONLY
static int get_ref_frame_flags(const VP9_COMP *cpi) {
const int *const map = cpi->common.ref_frame_map;
@@ -4696,6 +4748,7 @@ static void spatial_denoise_frame(VP9_COMP *cpi) {
}
#endif // ENABLE_KF_DENOISE
+#if !CONFIG_REALTIME_ONLY
static void vp9_try_disable_lookahead_aq(VP9_COMP *cpi, size_t *size,
uint8_t *dest) {
if (cpi->common.seg.enabled)
@@ -4719,6 +4772,7 @@ static void vp9_try_disable_lookahead_aq(VP9_COMP *cpi, size_t *size,
vp9_enable_segmentation(&cpi->common.seg);
}
}
+#endif
static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) {
RefCntBuffer *const ref_buffer = get_ref_cnt_buffer(cm, cm->new_fb_idx);
@@ -4737,15 +4791,9 @@ static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) {
// Some sample values are:
// (for midres test set)
// SSIM_VAR_SCALE avg_psnr ssim ms_ssim
-// 16.0 2.312 -3.062 -3.882
-// 32.0 0.852 -2.260 -2.821
-// 64.0 0.294 -1.606 -1.925
-// (for midres_10bd test set)
-// SSIM_VAR_SCALE avg_psnr ssim ms_ssim
-// 8.0 6.782 -3.872 -5.464
-// 16.0 3.189 -4.083 -5.258
-// 32.0 1.113 -3.423 -4.309
-// 64.0 0.241 -2.515 -3.074
+// 8.0 9.421 -5.537 -6.898
+// 16.0 4.703 -5.378 -6.238
+// 32.0 1.929 -4.308 -4.807
#define SSIM_VAR_SCALE 16.0
static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
@@ -4754,7 +4802,7 @@ static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
MACROBLOCKD *xd = &x->e_mbd;
uint8_t *y_buffer = cpi->Source->y_buffer;
const int y_stride = cpi->Source->y_stride;
- const int block_size = BLOCK_64X64;
+ const int block_size = BLOCK_16X16;
const int num_8x8_w = num_8x8_blocks_wide_lookup[block_size];
const int num_8x8_h = num_8x8_blocks_high_lookup[block_size];
@@ -4763,18 +4811,7 @@ static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
double log_sum = 0.0;
int row, col;
-#if CONFIG_VP9_HIGHBITDEPTH
- double c2;
- if (xd->bd == 10) {
- c2 = 941.8761; // (.03*1023)^2
- } else if (xd->bd == 12) {
- c2 = 15092.1225; // (.03*4095)^2
- } else {
- c2 = 58.5225; // (.03*255)^2
- }
-#else
- const double c2 = 58.5225; // (.03*255)^2
-#endif
+ const double c2 = 58.5225 * SSIM_VAR_SCALE; // 58.5225 = (.03*255)^2
// Loop through each 64x64 block.
for (row = 0; row < num_rows; ++row) {
@@ -4797,18 +4834,18 @@ static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
// In order to make SSIM_VAR_SCALE in a same scale for both 8 bit
// and high bit videos, the variance needs to be divided by 2.0 or
// 64.0 separately.
+ // TODO(sdeng): need to tune for 12bit videos.
#if CONFIG_VP9_HIGHBITDEPTH
if (cpi->Source->flags & YV12_FLAG_HIGHBITDEPTH)
- var +=
- vp9_high_get_sby_variance(cpi, &buf, BLOCK_8X8, xd->bd) / 2.0;
+ var += vp9_high_get_sby_variance(cpi, &buf, BLOCK_8X8, xd->bd);
else
#endif
- var += vp9_get_sby_variance(cpi, &buf, BLOCK_8X8) / 64.0;
+ var += vp9_get_sby_variance(cpi, &buf, BLOCK_8X8);
num_of_var += 1.0;
}
}
- var = var / num_of_var / SSIM_VAR_SCALE;
+ var = var / num_of_var / 64.0;
var = 2.0 * var + c2;
cpi->mi_ssim_rdmult_scaling_factors[index] = var;
log_sum += log(var);
@@ -5054,7 +5091,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
if (cpi->sf.recode_loop == DISALLOW_RECODE) {
if (!encode_without_recode_loop(cpi, size, dest)) return;
} else {
+#if !CONFIG_REALTIME_ONLY
encode_with_recode_loop(cpi, size, dest);
+#endif
}
// TODO(jingning): When using show existing frame mode, we assume that the
@@ -5066,9 +5105,11 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
cm->ref_frame_map[cpi->alt_fb_idx]);
}
+#if !CONFIG_REALTIME_ONLY
// Disable segmentation if it decrease rate/distortion ratio
if (cpi->oxcf.aq_mode == LOOKAHEAD_AQ)
vp9_try_disable_lookahead_aq(cpi, size, dest);
+#endif
#if CONFIG_VP9_TEMPORAL_DENOISING
#ifdef OUTPUT_YUV_DENOISED
@@ -5228,8 +5269,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
cpi->force_update_segmentation = 0;
+#if !CONFIG_REALTIME_ONLY
if (cpi->oxcf.aq_mode == LOOKAHEAD_AQ)
vp9_alt_ref_aq_unset_all(cpi->alt_ref_aq, cpi);
+#endif
cpi->svc.previous_frame_is_intra_only = cm->intra_only;
cpi->svc.set_intra_only_frame = 0;
@@ -5867,10 +5910,9 @@ static uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
#if CONFIG_NON_GREEDY_MV
// lambda is used to adjust the importance of motion vector consitency.
// TODO(angiebird): Figure out lambda's proper value.
- double lambda = cpi->tpl_stats[frame_idx].lambda;
+ const int lambda = cpi->tpl_stats[frame_idx].lambda;
int_mv nb_full_mvs[NB_MVS_NUM];
- double mv_dist;
- double mv_cost;
+ int nb_full_mv_num;
#endif
MV best_ref_mv1 = { 0, 0 };
@@ -5893,11 +5935,11 @@ static uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
#if CONFIG_NON_GREEDY_MV
(void)search_method;
(void)sadpb;
- vp9_prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx,
- bsize, nb_full_mvs);
+ nb_full_mv_num = vp9_prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row,
+ mi_col, rf_idx, bsize, nb_full_mvs);
vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda, 1,
- &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, mv,
- &mv_dist, &mv_cost);
+ &cpi->fn_ptr[bsize], nb_full_mvs, nb_full_mv_num,
+ mv);
#else
(void)frame_idx;
(void)mi_row;
@@ -6773,7 +6815,8 @@ static void build_motion_field(VP9_COMP *cpi, MACROBLOCKD *xd, int frame_idx,
int fs_loc_heap_size;
int mi_row, mi_col;
- tpl_frame->lambda = (pw * ph) / 4;
+ tpl_frame->lambda = (pw * ph) >> 2;
+ assert(pw * ph == tpl_frame->lambda << 2);
fs_loc_sort_size = 0;
for (mi_row = 0; mi_row < cm->mi_rows; mi_row += mi_height) {
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h
index ddba3275e44..f157fdfc5e8 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_encoder.h
@@ -29,7 +29,9 @@
#include "vp9/common/vp9_thread_common.h"
#include "vp9/common/vp9_onyxc_int.h"
+#if !CONFIG_REALTIME_ONLY
#include "vp9/encoder/vp9_alt_ref_aq.h"
+#endif
#include "vp9/encoder/vp9_aq_cyclicrefresh.h"
#include "vp9/encoder/vp9_context_tree.h"
#include "vp9/encoder/vp9_encodemb.h"
@@ -319,7 +321,7 @@ typedef struct TplDepFrame {
int mi_cols;
int base_qindex;
#if CONFIG_NON_GREEDY_MV
- double lambda;
+ int lambda;
int_mv *pyramid_mv_arr[3][SQUARE_BLOCK_SIZES];
int *mv_mode_arr[3];
double *rd_diff_arr[3];
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c
index 9b7f944b233..6947ee26f12 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.c
@@ -2048,15 +2048,31 @@ static int calculate_section_intra_ratio(const FIRSTPASS_STATS *begin,
// Calculate the total bits to allocate in this GF/ARF group.
static int64_t calculate_total_gf_group_bits(VP9_COMP *cpi,
double gf_group_err) {
+ VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
const TWO_PASS *const twopass = &cpi->twopass;
const int max_bits = frame_max_bits(rc, &cpi->oxcf);
int64_t total_group_bits;
+ const int is_key_frame = frame_is_intra_only(cm);
+ const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
+ int gop_frames =
+ rc->baseline_gf_interval + rc->source_alt_ref_pending - arf_active_or_kf;
// Calculate the bits to be allocated to the group as a whole.
if ((twopass->kf_group_bits > 0) && (twopass->kf_group_error_left > 0.0)) {
+ int key_frame_interval = rc->frames_since_key + rc->frames_to_key;
+ int distance_from_next_key_frame =
+ rc->frames_to_key -
+ (rc->baseline_gf_interval + rc->source_alt_ref_pending);
+ int max_gf_bits_bias = rc->avg_frame_bandwidth;
+ double gf_interval_bias_bits_normalize_factor =
+ (double)rc->baseline_gf_interval / 16;
total_group_bits = (int64_t)(twopass->kf_group_bits *
(gf_group_err / twopass->kf_group_error_left));
+ // TODO(ravi): Experiment with different values of max_gf_bits_bias
+ total_group_bits +=
+ (int64_t)((double)distance_from_next_key_frame / key_frame_interval *
+ max_gf_bits_bias * gf_interval_bias_bits_normalize_factor);
} else {
total_group_bits = 0;
}
@@ -2069,8 +2085,8 @@ static int64_t calculate_total_gf_group_bits(VP9_COMP *cpi,
: total_group_bits;
// Clip based on user supplied data rate variability limit.
- if (total_group_bits > (int64_t)max_bits * rc->baseline_gf_interval)
- total_group_bits = (int64_t)max_bits * rc->baseline_gf_interval;
+ if (total_group_bits > (int64_t)max_bits * gop_frames)
+ total_group_bits = (int64_t)max_bits * gop_frames;
return total_group_bits;
}
@@ -2290,7 +2306,7 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits,
// Define middle frame
mid_frame_idx = frame_index + (rc->baseline_gf_interval >> 1) - 1;
- normal_frames = (rc->baseline_gf_interval - rc->source_alt_ref_pending);
+ normal_frames = (rc->baseline_gf_interval - 1);
if (normal_frames > 1)
normal_frame_bits = (int)(total_group_bits / normal_frames);
else
@@ -2450,8 +2466,10 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
int gf_arf_bits;
const int is_key_frame = frame_is_intra_only(cm);
const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
+ int is_alt_ref_flash = 0;
double gop_intra_factor = 1.0;
+ int gop_frames;
// Reset the GF group data structures unless this is a key
// frame in which case it will already have been done.
@@ -2644,13 +2662,27 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
#define LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR 0.2
rc->arf_active_best_quality_adjustment_factor = 1.0;
- if (rc->source_alt_ref_pending && !is_lossless_requested(&cpi->oxcf) &&
- rc->frames_to_key <= rc->arf_active_best_quality_adjustment_window) {
- rc->arf_active_best_quality_adjustment_factor =
- LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR +
- (1.0 - LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR) *
- (rc->frames_to_key - i) /
- VPXMAX(1, (rc->arf_active_best_quality_adjustment_window - i));
+ rc->arf_increase_active_best_quality = 0;
+
+ if (!is_lossless_requested(&cpi->oxcf)) {
+ if (rc->frames_since_key >= rc->frames_to_key) {
+ // Increase the active best quality in the second half of key frame
+ // interval.
+ rc->arf_active_best_quality_adjustment_factor =
+ LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR +
+ (1.0 - LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR) *
+ (rc->frames_to_key - i) /
+ (VPXMAX(1, ((rc->frames_to_key + rc->frames_since_key) / 2 - i)));
+ rc->arf_increase_active_best_quality = 1;
+ } else if ((rc->frames_to_key - i) > 0) {
+ // Reduce the active best quality in the first half of key frame interval.
+ rc->arf_active_best_quality_adjustment_factor =
+ LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR +
+ (1.0 - LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR) *
+ (rc->frames_since_key + i) /
+ (VPXMAX(1, (rc->frames_to_key + rc->frames_since_key) / 2 + i));
+ rc->arf_increase_active_best_quality = -1;
+ }
}
#ifdef AGGRESSIVE_VBR
@@ -2672,12 +2704,22 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Reset the file position.
reset_fpf_position(twopass, start_pos);
+ if (rc->source_alt_ref_pending)
+ is_alt_ref_flash = detect_flash(twopass, rc->baseline_gf_interval);
+
// Calculate the bits to be allocated to the gf/arf group as a whole
gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);
+ gop_frames =
+ rc->baseline_gf_interval + rc->source_alt_ref_pending - arf_active_or_kf;
+
// Store the average moise level measured for the group
- twopass->gf_group.group_noise_energy =
- (int)(gf_group_noise / rc->baseline_gf_interval);
+ // TODO(any): Experiment with removal of else condition (gop_frames = 0) so
+ // that consumption of group noise energy is based on previous gf group
+ if (gop_frames > 0)
+ twopass->gf_group.group_noise_energy = (int)(gf_group_noise / gop_frames);
+ else
+ twopass->gf_group.group_noise_energy = 0;
// Calculate an estimate of the maxq needed for the group.
// We are more aggressive about correcting for sections
@@ -2685,15 +2727,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// sections where we do not wish to risk creating an overshoot
// of the allocated bit budget.
if ((cpi->oxcf.rc_mode != VPX_Q) && (rc->baseline_gf_interval > 1)) {
- const int vbr_group_bits_per_frame =
- (int)(gf_group_bits / rc->baseline_gf_interval);
- const double group_av_err = gf_group_raw_error / rc->baseline_gf_interval;
- const double group_av_noise = gf_group_noise / rc->baseline_gf_interval;
- const double group_av_skip_pct =
- gf_group_skip_pct / rc->baseline_gf_interval;
- const double group_av_inactive_zone =
- ((gf_group_inactive_zone_rows * 2) /
- (rc->baseline_gf_interval * (double)cm->mb_rows));
+ const int vbr_group_bits_per_frame = (int)(gf_group_bits / gop_frames);
+ const double group_av_err = gf_group_raw_error / gop_frames;
+ const double group_av_noise = gf_group_noise / gop_frames;
+ const double group_av_skip_pct = gf_group_skip_pct / gop_frames;
+ const double group_av_inactive_zone = ((gf_group_inactive_zone_rows * 2) /
+ (gop_frames * (double)cm->mb_rows));
int tmp_q = get_twopass_worst_quality(
cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone),
group_av_noise, vbr_group_bits_per_frame);
@@ -2709,9 +2748,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Context Adjustment of ARNR filter strength
if (rc->baseline_gf_interval > 1) {
- adjust_group_arnr_filter(cpi, (gf_group_noise / rc->baseline_gf_interval),
- (gf_group_inter / rc->baseline_gf_interval),
- (gf_group_motion / rc->baseline_gf_interval));
+ adjust_group_arnr_filter(cpi, (gf_group_noise / gop_frames),
+ (gf_group_inter / gop_frames),
+ (gf_group_motion / gop_frames));
} else {
twopass->arnr_strength_adjustment = 0;
}
@@ -2745,6 +2784,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
twopass->rolling_arf_group_target_bits = 0;
twopass->rolling_arf_group_actual_bits = 0;
#endif
+ rc->preserve_arf_as_gld = rc->preserve_next_arf_as_gld;
+ rc->preserve_next_arf_as_gld = 0;
+ // If alt ref frame is flash do not set preserve_arf_as_gld
+ if (!is_lossless_requested(&cpi->oxcf) && !cpi->use_svc &&
+ cpi->oxcf.aq_mode == NO_AQ && cpi->multi_layer_arf && !is_alt_ref_flash)
+ rc->preserve_next_arf_as_gld = 1;
}
// Intra / Inter threshold very low
@@ -2929,6 +2974,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
FIRSTPASS_STATS next_frame;
FIRSTPASS_STATS last_frame;
int kf_bits = 0;
+ int64_t max_kf_bits;
double decay_accumulator = 1.0;
double zero_motion_accumulator = 1.0;
double zero_motion_sum = 0.0;
@@ -3179,6 +3225,13 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Work out how many bits to allocate for the key frame itself.
kf_bits = calculate_boost_bits((rc->frames_to_key - 1), rc->kf_boost,
twopass->kf_group_bits);
+ // Based on the spatial complexity, increase the bits allocated to key frame.
+ kf_bits +=
+ (int)((twopass->kf_group_bits - kf_bits) * (kf_mod_err / kf_group_err));
+ max_kf_bits =
+ twopass->kf_group_bits - (rc->frames_to_key - 1) * FRAME_OVERHEAD_BITS;
+ max_kf_bits = lclamp(max_kf_bits, 0, INT_MAX);
+ kf_bits = VPXMIN(kf_bits, (int)max_kf_bits);
twopass->kf_group_bits -= kf_bits;
@@ -3186,6 +3239,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
gf_group->bit_allocation[0] = kf_bits;
gf_group->update_type[0] = KF_UPDATE;
gf_group->rf_level[0] = KF_STD;
+ gf_group->layer_depth[0] = 0;
// Note the total error score of the kf group minus the key frame itself.
twopass->kf_group_error_left = (kf_group_err - kf_mod_err);
@@ -3199,11 +3253,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Default to normal-sized frame on keyframes.
cpi->rc.next_frame_size_selector = UNSCALED;
}
-#define ARF_ACTIVE_BEST_QUALITY_ADJUSTMENT_WINDOW_SIZE 64
- // TODO(ravi.chaudhary@ittiam.com): Experiment without the below min
- // condition. This might be helpful for small key frame intervals.
- rc->arf_active_best_quality_adjustment_window =
- VPXMIN(ARF_ACTIVE_BEST_QUALITY_ADJUSTMENT_WINDOW_SIZE, rc->frames_to_key);
}
static int is_skippable_frame(const VP9_COMP *cpi) {
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h
index a0a96e6ef63..bf256017319 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h
@@ -192,6 +192,7 @@ typedef struct {
int extend_maxq;
int extend_minq_fast;
int arnr_strength_adjustment;
+ int last_qindex_of_arf_layer[MAX_ARF_LAYERS];
GF_GROUP gf_group;
} TWO_PASS;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c
index b82cbcdaa74..a11bf6acd60 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.c
@@ -1731,68 +1731,295 @@ static int exhaustive_mesh_search(const MACROBLOCK *x, MV *ref_mv, MV *best_mv,
#define MAX_RANGE 256
#define MIN_INTERVAL 1
#if CONFIG_NON_GREEDY_MV
-double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
- int mv_num) {
+
+#define LOG2_TABLE_SIZE 1024
+static const int log2_table[LOG2_TABLE_SIZE] = {
+ 0, // This is a dummy value
+ 0, 1048576, 1661954, 2097152, 2434718, 2710530, 2943725,
+ 3145728, 3323907, 3483294, 3627477, 3759106, 3880192, 3992301,
+ 4096672, 4194304, 4286015, 4372483, 4454275, 4531870, 4605679,
+ 4676053, 4743299, 4807682, 4869436, 4928768, 4985861, 5040877,
+ 5093962, 5145248, 5194851, 5242880, 5289431, 5334591, 5378443,
+ 5421059, 5462508, 5502851, 5542146, 5580446, 5617800, 5654255,
+ 5689851, 5724629, 5758625, 5791875, 5824409, 5856258, 5887450,
+ 5918012, 5947969, 5977344, 6006160, 6034437, 6062195, 6089453,
+ 6116228, 6142538, 6168398, 6193824, 6218829, 6243427, 6267632,
+ 6291456, 6314910, 6338007, 6360756, 6383167, 6405252, 6427019,
+ 6448477, 6469635, 6490501, 6511084, 6531390, 6551427, 6571202,
+ 6590722, 6609993, 6629022, 6647815, 6666376, 6684713, 6702831,
+ 6720734, 6738427, 6755916, 6773205, 6790299, 6807201, 6823917,
+ 6840451, 6856805, 6872985, 6888993, 6904834, 6920510, 6936026,
+ 6951384, 6966588, 6981641, 6996545, 7011304, 7025920, 7040397,
+ 7054736, 7068940, 7083013, 7096956, 7110771, 7124461, 7138029,
+ 7151476, 7164804, 7178017, 7191114, 7204100, 7216974, 7229740,
+ 7242400, 7254954, 7267405, 7279754, 7292003, 7304154, 7316208,
+ 7328167, 7340032, 7351805, 7363486, 7375079, 7386583, 7398000,
+ 7409332, 7420579, 7431743, 7442826, 7453828, 7464751, 7475595,
+ 7486362, 7497053, 7507669, 7518211, 7528680, 7539077, 7549404,
+ 7559660, 7569847, 7579966, 7590017, 7600003, 7609923, 7619778,
+ 7629569, 7639298, 7648964, 7658569, 7668114, 7677598, 7687023,
+ 7696391, 7705700, 7714952, 7724149, 7733289, 7742375, 7751407,
+ 7760385, 7769310, 7778182, 7787003, 7795773, 7804492, 7813161,
+ 7821781, 7830352, 7838875, 7847350, 7855777, 7864158, 7872493,
+ 7880782, 7889027, 7897226, 7905381, 7913492, 7921561, 7929586,
+ 7937569, 7945510, 7953410, 7961268, 7969086, 7976864, 7984602,
+ 7992301, 7999960, 8007581, 8015164, 8022709, 8030217, 8037687,
+ 8045121, 8052519, 8059880, 8067206, 8074496, 8081752, 8088973,
+ 8096159, 8103312, 8110431, 8117516, 8124569, 8131589, 8138576,
+ 8145532, 8152455, 8159347, 8166208, 8173037, 8179836, 8186605,
+ 8193343, 8200052, 8206731, 8213380, 8220001, 8226593, 8233156,
+ 8239690, 8246197, 8252676, 8259127, 8265550, 8271947, 8278316,
+ 8284659, 8290976, 8297266, 8303530, 8309768, 8315981, 8322168,
+ 8328330, 8334467, 8340579, 8346667, 8352730, 8358769, 8364784,
+ 8370775, 8376743, 8382687, 8388608, 8394506, 8400381, 8406233,
+ 8412062, 8417870, 8423655, 8429418, 8435159, 8440878, 8446576,
+ 8452252, 8457908, 8463542, 8469155, 8474748, 8480319, 8485871,
+ 8491402, 8496913, 8502404, 8507875, 8513327, 8518759, 8524171,
+ 8529564, 8534938, 8540293, 8545629, 8550947, 8556245, 8561525,
+ 8566787, 8572031, 8577256, 8582464, 8587653, 8592825, 8597980,
+ 8603116, 8608236, 8613338, 8618423, 8623491, 8628542, 8633576,
+ 8638593, 8643594, 8648579, 8653547, 8658499, 8663434, 8668354,
+ 8673258, 8678145, 8683017, 8687874, 8692715, 8697540, 8702350,
+ 8707145, 8711925, 8716690, 8721439, 8726174, 8730894, 8735599,
+ 8740290, 8744967, 8749628, 8754276, 8758909, 8763528, 8768134,
+ 8772725, 8777302, 8781865, 8786415, 8790951, 8795474, 8799983,
+ 8804478, 8808961, 8813430, 8817886, 8822328, 8826758, 8831175,
+ 8835579, 8839970, 8844349, 8848715, 8853068, 8857409, 8861737,
+ 8866053, 8870357, 8874649, 8878928, 8883195, 8887451, 8891694,
+ 8895926, 8900145, 8904353, 8908550, 8912734, 8916908, 8921069,
+ 8925220, 8929358, 8933486, 8937603, 8941708, 8945802, 8949885,
+ 8953957, 8958018, 8962068, 8966108, 8970137, 8974155, 8978162,
+ 8982159, 8986145, 8990121, 8994086, 8998041, 9001986, 9005920,
+ 9009844, 9013758, 9017662, 9021556, 9025440, 9029314, 9033178,
+ 9037032, 9040877, 9044711, 9048536, 9052352, 9056157, 9059953,
+ 9063740, 9067517, 9071285, 9075044, 9078793, 9082533, 9086263,
+ 9089985, 9093697, 9097400, 9101095, 9104780, 9108456, 9112123,
+ 9115782, 9119431, 9123072, 9126704, 9130328, 9133943, 9137549,
+ 9141146, 9144735, 9148316, 9151888, 9155452, 9159007, 9162554,
+ 9166092, 9169623, 9173145, 9176659, 9180165, 9183663, 9187152,
+ 9190634, 9194108, 9197573, 9201031, 9204481, 9207923, 9211357,
+ 9214784, 9218202, 9221613, 9225017, 9228412, 9231800, 9235181,
+ 9238554, 9241919, 9245277, 9248628, 9251971, 9255307, 9258635,
+ 9261956, 9265270, 9268577, 9271876, 9275169, 9278454, 9281732,
+ 9285002, 9288266, 9291523, 9294773, 9298016, 9301252, 9304481,
+ 9307703, 9310918, 9314126, 9317328, 9320523, 9323711, 9326892,
+ 9330067, 9333235, 9336397, 9339552, 9342700, 9345842, 9348977,
+ 9352106, 9355228, 9358344, 9361454, 9364557, 9367654, 9370744,
+ 9373828, 9376906, 9379978, 9383043, 9386102, 9389155, 9392202,
+ 9395243, 9398278, 9401306, 9404329, 9407345, 9410356, 9413360,
+ 9416359, 9419351, 9422338, 9425319, 9428294, 9431263, 9434226,
+ 9437184, 9440136, 9443082, 9446022, 9448957, 9451886, 9454809,
+ 9457726, 9460638, 9463545, 9466446, 9469341, 9472231, 9475115,
+ 9477994, 9480867, 9483735, 9486597, 9489454, 9492306, 9495152,
+ 9497993, 9500828, 9503659, 9506484, 9509303, 9512118, 9514927,
+ 9517731, 9520530, 9523324, 9526112, 9528895, 9531674, 9534447,
+ 9537215, 9539978, 9542736, 9545489, 9548237, 9550980, 9553718,
+ 9556451, 9559179, 9561903, 9564621, 9567335, 9570043, 9572747,
+ 9575446, 9578140, 9580830, 9583514, 9586194, 9588869, 9591540,
+ 9594205, 9596866, 9599523, 9602174, 9604821, 9607464, 9610101,
+ 9612735, 9615363, 9617987, 9620607, 9623222, 9625832, 9628438,
+ 9631040, 9633637, 9636229, 9638818, 9641401, 9643981, 9646556,
+ 9649126, 9651692, 9654254, 9656812, 9659365, 9661914, 9664459,
+ 9666999, 9669535, 9672067, 9674594, 9677118, 9679637, 9682152,
+ 9684663, 9687169, 9689672, 9692170, 9694665, 9697155, 9699641,
+ 9702123, 9704601, 9707075, 9709545, 9712010, 9714472, 9716930,
+ 9719384, 9721834, 9724279, 9726721, 9729159, 9731593, 9734024,
+ 9736450, 9738872, 9741291, 9743705, 9746116, 9748523, 9750926,
+ 9753326, 9755721, 9758113, 9760501, 9762885, 9765266, 9767642,
+ 9770015, 9772385, 9774750, 9777112, 9779470, 9781825, 9784175,
+ 9786523, 9788866, 9791206, 9793543, 9795875, 9798204, 9800530,
+ 9802852, 9805170, 9807485, 9809797, 9812104, 9814409, 9816710,
+ 9819007, 9821301, 9823591, 9825878, 9828161, 9830441, 9832718,
+ 9834991, 9837261, 9839527, 9841790, 9844050, 9846306, 9848559,
+ 9850808, 9853054, 9855297, 9857537, 9859773, 9862006, 9864235,
+ 9866462, 9868685, 9870904, 9873121, 9875334, 9877544, 9879751,
+ 9881955, 9884155, 9886352, 9888546, 9890737, 9892925, 9895109,
+ 9897291, 9899469, 9901644, 9903816, 9905985, 9908150, 9910313,
+ 9912473, 9914629, 9916783, 9918933, 9921080, 9923225, 9925366,
+ 9927504, 9929639, 9931771, 9933900, 9936027, 9938150, 9940270,
+ 9942387, 9944502, 9946613, 9948721, 9950827, 9952929, 9955029,
+ 9957126, 9959219, 9961310, 9963398, 9965484, 9967566, 9969645,
+ 9971722, 9973796, 9975866, 9977934, 9980000, 9982062, 9984122,
+ 9986179, 9988233, 9990284, 9992332, 9994378, 9996421, 9998461,
+ 10000498, 10002533, 10004565, 10006594, 10008621, 10010644, 10012665,
+ 10014684, 10016700, 10018713, 10020723, 10022731, 10024736, 10026738,
+ 10028738, 10030735, 10032729, 10034721, 10036710, 10038697, 10040681,
+ 10042662, 10044641, 10046617, 10048591, 10050562, 10052530, 10054496,
+ 10056459, 10058420, 10060379, 10062334, 10064287, 10066238, 10068186,
+ 10070132, 10072075, 10074016, 10075954, 10077890, 10079823, 10081754,
+ 10083682, 10085608, 10087532, 10089453, 10091371, 10093287, 10095201,
+ 10097112, 10099021, 10100928, 10102832, 10104733, 10106633, 10108529,
+ 10110424, 10112316, 10114206, 10116093, 10117978, 10119861, 10121742,
+ 10123620, 10125495, 10127369, 10129240, 10131109, 10132975, 10134839,
+ 10136701, 10138561, 10140418, 10142273, 10144126, 10145976, 10147825,
+ 10149671, 10151514, 10153356, 10155195, 10157032, 10158867, 10160699,
+ 10162530, 10164358, 10166184, 10168007, 10169829, 10171648, 10173465,
+ 10175280, 10177093, 10178904, 10180712, 10182519, 10184323, 10186125,
+ 10187925, 10189722, 10191518, 10193311, 10195103, 10196892, 10198679,
+ 10200464, 10202247, 10204028, 10205806, 10207583, 10209357, 10211130,
+ 10212900, 10214668, 10216435, 10218199, 10219961, 10221721, 10223479,
+ 10225235, 10226989, 10228741, 10230491, 10232239, 10233985, 10235728,
+ 10237470, 10239210, 10240948, 10242684, 10244417, 10246149, 10247879,
+ 10249607, 10251333, 10253057, 10254779, 10256499, 10258217, 10259933,
+ 10261647, 10263360, 10265070, 10266778, 10268485, 10270189, 10271892,
+ 10273593, 10275292, 10276988, 10278683, 10280376, 10282068, 10283757,
+ 10285444, 10287130, 10288814, 10290495, 10292175, 10293853, 10295530,
+ 10297204, 10298876, 10300547, 10302216, 10303883, 10305548, 10307211,
+ 10308873, 10310532, 10312190, 10313846, 10315501, 10317153, 10318804,
+ 10320452, 10322099, 10323745, 10325388, 10327030, 10328670, 10330308,
+ 10331944, 10333578, 10335211, 10336842, 10338472, 10340099, 10341725,
+ 10343349, 10344971, 10346592, 10348210, 10349828, 10351443, 10353057,
+ 10354668, 10356279, 10357887, 10359494, 10361099, 10362702, 10364304,
+ 10365904, 10367502, 10369099, 10370694, 10372287, 10373879, 10375468,
+ 10377057, 10378643, 10380228, 10381811, 10383393, 10384973, 10386551,
+ 10388128, 10389703, 10391276, 10392848, 10394418, 10395986, 10397553,
+ 10399118, 10400682, 10402244, 10403804, 10405363, 10406920, 10408476,
+ 10410030, 10411582, 10413133, 10414682, 10416230, 10417776, 10419320,
+ 10420863, 10422404, 10423944, 10425482, 10427019, 10428554, 10430087,
+ 10431619, 10433149, 10434678, 10436206, 10437731, 10439256, 10440778,
+ 10442299, 10443819, 10445337, 10446854, 10448369, 10449882, 10451394,
+ 10452905, 10454414, 10455921, 10457427, 10458932, 10460435, 10461936,
+ 10463436, 10464935, 10466432, 10467927, 10469422, 10470914, 10472405,
+ 10473895, 10475383, 10476870, 10478355, 10479839, 10481322, 10482802,
+ 10484282,
+};
+
+#define LOG2_PRECISION 20
+static int64_t log2_approximation(int64_t v) {
+ assert(v > 0);
+ if (v < LOG2_TABLE_SIZE) {
+ return log2_table[v];
+ } else {
+ // use linear approximation when v >= 2^10
+ const int slope =
+ 1477; // slope = 1 / (log(2) * 1024) * (1 << LOG2_PRECISION)
+ assert(LOG2_TABLE_SIZE == 1 << 10);
+
+ return slope * (v - LOG2_TABLE_SIZE) + (10 << LOG2_PRECISION);
+ }
+}
+
+int64_t vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_full_mvs,
+ int mv_num) {
+ // The bahavior of this function is to compute log2 of mv difference,
+ // i.e. min log2(1 + row_diff * row_diff + col_diff * col_diff)
+ // against available neghbor mvs.
+ // Since the log2 is monotonic increasing, we can compute
+ // min row_diff * row_diff + col_diff * col_diff first
+ // then apply log2 in the end
int i;
- int update = 0;
- double best_cost = 0;
- vpx_clear_system_state();
+ int64_t min_abs_diff = INT64_MAX;
+ int cnt = 0;
+ assert(mv_num <= NB_MVS_NUM);
for (i = 0; i < mv_num; ++i) {
- if (nb_mvs[i].as_int != INVALID_MV) {
- MV nb_mv = nb_mvs[i].as_mv;
- const double row_diff = mv->row - nb_mv.row;
- const double col_diff = mv->col - nb_mv.col;
- double cost = row_diff * row_diff + col_diff * col_diff;
- cost = log2(1 + cost);
- if (update == 0) {
- best_cost = cost;
- update = 1;
- } else {
- best_cost = cost < best_cost ? cost : best_cost;
+ MV nb_mv = nb_full_mvs[i].as_mv;
+ const int64_t row_diff = abs(mv->row - nb_mv.row);
+ const int64_t col_diff = abs(mv->col - nb_mv.col);
+ const int64_t abs_diff = row_diff * row_diff + col_diff * col_diff;
+ assert(nb_full_mvs[i].as_int != INVALID_MV);
+ min_abs_diff = VPXMIN(abs_diff, min_abs_diff);
+ ++cnt;
+ }
+ if (cnt) {
+ return log2_approximation(1 + min_abs_diff);
+ } else {
+ return 0;
+ }
+}
+
+static int64_t exhaustive_mesh_search_multi_step(
+ MV *best_mv, const MV *center_mv, int range, int step,
+ const struct buf_2d *src, const struct buf_2d *pre, int lambda,
+ const int_mv *nb_full_mvs, int full_mv_num, const MvLimits *mv_limits,
+ const vp9_variance_fn_ptr_t *fn_ptr) {
+ int64_t best_sad;
+ int r, c;
+ int start_col, end_col, start_row, end_row;
+ *best_mv = *center_mv;
+ best_sad =
+ ((int64_t)fn_ptr->sdf(src->buf, src->stride,
+ get_buf_from_mv(pre, center_mv), pre->stride)
+ << LOG2_PRECISION) +
+ lambda * vp9_nb_mvs_inconsistency(best_mv, nb_full_mvs, full_mv_num);
+ start_row = VPXMAX(center_mv->row - range, mv_limits->row_min);
+ start_col = VPXMAX(center_mv->col - range, mv_limits->col_min);
+ end_row = VPXMIN(center_mv->row + range, mv_limits->row_max);
+ end_col = VPXMIN(center_mv->col + range, mv_limits->col_max);
+ for (r = start_row; r <= end_row; r += step) {
+ for (c = start_col; c <= end_col; c += step) {
+ const MV mv = { r, c };
+ int64_t sad = (int64_t)fn_ptr->sdf(src->buf, src->stride,
+ get_buf_from_mv(pre, &mv), pre->stride)
+ << LOG2_PRECISION;
+ if (sad < best_sad) {
+ sad += lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+ if (sad < best_sad) {
+ best_sad = sad;
+ *best_mv = mv;
+ }
}
}
}
- return best_cost;
+ return best_sad;
}
-static double exhaustive_mesh_search_new(const MACROBLOCK *x, MV *best_mv,
- int range, int step,
- const vp9_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv, double lambda,
- const int_mv *nb_full_mvs,
- int full_mv_num) {
- const MACROBLOCKD *const xd = &x->e_mbd;
- const struct buf_2d *const what = &x->plane[0].src;
- const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- MV fcenter_mv = { center_mv->row, center_mv->col };
- double best_sad;
+static int64_t exhaustive_mesh_search_single_step(
+ MV *best_mv, const MV *center_mv, int range, const struct buf_2d *src,
+ const struct buf_2d *pre, int lambda, const int_mv *nb_full_mvs,
+ int full_mv_num, const MvLimits *mv_limits,
+ const vp9_variance_fn_ptr_t *fn_ptr) {
+ int64_t best_sad;
int r, c, i;
int start_col, end_col, start_row, end_row;
- int col_step = (step > 1) ? step : 4;
- assert(step >= 1);
-
- clamp_mv(&fcenter_mv, x->mv_limits.col_min, x->mv_limits.col_max,
- x->mv_limits.row_min, x->mv_limits.row_max);
- *best_mv = fcenter_mv;
+ *best_mv = *center_mv;
best_sad =
- fn_ptr->sdf(what->buf, what->stride,
- get_buf_from_mv(in_what, &fcenter_mv), in_what->stride) +
- lambda * vp9_nb_mvs_inconsistency(&fcenter_mv, nb_full_mvs, full_mv_num);
- start_row = VPXMAX(-range, x->mv_limits.row_min - fcenter_mv.row);
- start_col = VPXMAX(-range, x->mv_limits.col_min - fcenter_mv.col);
- end_row = VPXMIN(range, x->mv_limits.row_max - fcenter_mv.row);
- end_col = VPXMIN(range, x->mv_limits.col_max - fcenter_mv.col);
+ ((int64_t)fn_ptr->sdf(src->buf, src->stride,
+ get_buf_from_mv(pre, center_mv), pre->stride)
+ << LOG2_PRECISION) +
+ lambda * vp9_nb_mvs_inconsistency(best_mv, nb_full_mvs, full_mv_num);
+ start_row = VPXMAX(center_mv->row - range, mv_limits->row_min);
+ start_col = VPXMAX(center_mv->col - range, mv_limits->col_min);
+ end_row = VPXMIN(center_mv->row + range, mv_limits->row_max);
+ end_col = VPXMIN(center_mv->col + range, mv_limits->col_max);
+ for (r = start_row; r <= end_row; r += 1) {
+ c = start_col;
+ // sdx8f may not be available some block size
+ if (fn_ptr->sdx8f) {
+ while (c + 7 <= end_col) {
+ unsigned int sads[8];
+ const MV mv = { r, c };
+ const uint8_t *buf = get_buf_from_mv(pre, &mv);
+ fn_ptr->sdx8f(src->buf, src->stride, buf, pre->stride, sads);
+
+ for (i = 0; i < 8; ++i) {
+ int64_t sad = (int64_t)sads[i] << LOG2_PRECISION;
+ if (sad < best_sad) {
+ const MV mv = { r, c + i };
+ sad += lambda *
+ vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+ if (sad < best_sad) {
+ best_sad = sad;
+ *best_mv = mv;
+ }
+ }
+ }
+ c += 8;
+ }
+ }
+ while (c + 3 <= end_col) {
+ unsigned int sads[4];
+ const uint8_t *addrs[4];
+ for (i = 0; i < 4; ++i) {
+ const MV mv = { r, c + i };
+ addrs[i] = get_buf_from_mv(pre, &mv);
+ }
+ fn_ptr->sdx4df(src->buf, src->stride, addrs, pre->stride, sads);
- for (r = start_row; r <= end_row; r += step) {
- for (c = start_col; c <= end_col; c += col_step) {
- // Step > 1 means we are not checking every location in this pass.
- if (step > 1) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c };
- double sad =
- fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv),
- in_what->stride);
+ for (i = 0; i < 4; ++i) {
+ int64_t sad = (int64_t)sads[i] << LOG2_PRECISION;
if (sad < best_sad) {
+ const MV mv = { r, c + i };
sad +=
lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
if (sad < best_sad) {
@@ -1800,66 +2027,61 @@ static double exhaustive_mesh_search_new(const MACROBLOCK *x, MV *best_mv,
*best_mv = mv;
}
}
- } else {
- // 4 sads in a single call if we are checking every location
- if (c + 3 <= end_col) {
- unsigned int sads[4];
- const uint8_t *addrs[4];
- for (i = 0; i < 4; ++i) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
- addrs[i] = get_buf_from_mv(in_what, &mv);
- }
- fn_ptr->sdx4df(what->buf, what->stride, addrs, in_what->stride, sads);
-
- for (i = 0; i < 4; ++i) {
- if (sads[i] < best_sad) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
- const double sad =
- sads[i] + lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs,
- full_mv_num);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- }
- } else {
- for (i = 0; i < end_col - c; ++i) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
- double sad =
- fn_ptr->sdf(what->buf, what->stride,
- get_buf_from_mv(in_what, &mv), in_what->stride);
- if (sad < best_sad) {
- sad += lambda *
- vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- }
+ }
+ c += 4;
+ }
+ while (c <= end_col) {
+ const MV mv = { r, c };
+ int64_t sad = (int64_t)fn_ptr->sdf(src->buf, src->stride,
+ get_buf_from_mv(pre, &mv), pre->stride)
+ << LOG2_PRECISION;
+ if (sad < best_sad) {
+ sad += lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+ if (sad < best_sad) {
+ best_sad = sad;
+ *best_mv = mv;
}
}
+ c += 1;
}
}
-
return best_sad;
}
-static double full_pixel_exhaustive_new(const VP9_COMP *cpi, MACROBLOCK *x,
- MV *centre_mv_full,
- const vp9_variance_fn_ptr_t *fn_ptr,
- MV *dst_mv, double lambda,
- const int_mv *nb_full_mvs,
- int full_mv_num) {
+static int64_t exhaustive_mesh_search_new(const MACROBLOCK *x, MV *best_mv,
+ int range, int step,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const MV *center_mv, int lambda,
+ const int_mv *nb_full_mvs,
+ int full_mv_num) {
+ const MACROBLOCKD *const xd = &x->e_mbd;
+ const struct buf_2d *src = &x->plane[0].src;
+ const struct buf_2d *pre = &xd->plane[0].pre[0];
+ assert(step >= 1);
+ assert(is_mv_in(&x->mv_limits, center_mv));
+ if (step == 1) {
+ return exhaustive_mesh_search_single_step(
+ best_mv, center_mv, range, src, pre, lambda, nb_full_mvs, full_mv_num,
+ &x->mv_limits, fn_ptr);
+ }
+ return exhaustive_mesh_search_multi_step(best_mv, center_mv, range, step, src,
+ pre, lambda, nb_full_mvs,
+ full_mv_num, &x->mv_limits, fn_ptr);
+}
+
+static int64_t full_pixel_exhaustive_new(const VP9_COMP *cpi, MACROBLOCK *x,
+ MV *centre_mv_full,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ MV *dst_mv, int lambda,
+ const int_mv *nb_full_mvs,
+ int full_mv_num) {
const SPEED_FEATURES *const sf = &cpi->sf;
MV temp_mv = { centre_mv_full->row, centre_mv_full->col };
- double bestsme;
+ int64_t bestsme;
int i;
int interval = sf->mesh_patterns[0].interval;
int range = sf->mesh_patterns[0].range;
int baseline_interval_divisor;
- const MV dummy_mv = { 0, 0 };
// Trap illegal values for interval and range for this function.
if ((range < MIN_RANGE) || (range > MAX_RANGE) || (interval < MIN_INTERVAL) ||
@@ -1895,18 +2117,18 @@ static double full_pixel_exhaustive_new(const VP9_COMP *cpi, MACROBLOCK *x,
}
}
- bestsme = vp9_get_mvpred_var(x, &temp_mv, &dummy_mv, fn_ptr, 0);
*dst_mv = temp_mv;
return bestsme;
}
-static double diamond_search_sad_new(
- const MACROBLOCK *x, const search_site_config *cfg, const MV *init_full_mv,
- MV *best_full_mv, double *best_mv_dist, double *best_mv_cost,
- int search_param, double lambda, int *num00,
- const vp9_variance_fn_ptr_t *fn_ptr, const int_mv *nb_full_mvs,
- int full_mv_num) {
+static int64_t diamond_search_sad_new(const MACROBLOCK *x,
+ const search_site_config *cfg,
+ const MV *init_full_mv, MV *best_full_mv,
+ int search_param, int lambda, int *num00,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const int_mv *nb_full_mvs,
+ int full_mv_num) {
int i, j, step;
const MACROBLOCKD *const xd = &x->e_mbd;
@@ -1916,7 +2138,7 @@ static double diamond_search_sad_new(
const int in_what_stride = xd->plane[0].pre[0].stride;
const uint8_t *best_address;
- double bestsad;
+ int64_t bestsad;
int best_site = -1;
int last_site = -1;
@@ -1942,10 +2164,14 @@ static double diamond_search_sad_new(
best_address = in_what;
// Check the starting position
- *best_mv_dist = fn_ptr->sdf(what, what_stride, in_what, in_what_stride);
- *best_mv_cost =
- vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
- bestsad = (*best_mv_dist) + lambda * (*best_mv_cost);
+ {
+ const int64_t mv_dist =
+ (int64_t)fn_ptr->sdf(what, what_stride, in_what, in_what_stride)
+ << LOG2_PRECISION;
+ const int64_t mv_cost =
+ vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
+ bestsad = mv_dist + lambda * mv_cost;
+ }
i = 0;
@@ -1974,17 +2200,17 @@ static double diamond_search_sad_new(
sad_array);
for (t = 0; t < 4; t++, i++) {
- const MV this_mv = { best_full_mv->row + ss_mv[i].row,
- best_full_mv->col + ss_mv[i].col };
- const double mv_dist = sad_array[t];
- const double mv_cost =
- vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
- double thissad = mv_dist + lambda * mv_cost;
- if (thissad < bestsad) {
- bestsad = thissad;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
- best_site = i;
+ const int64_t mv_dist = (int64_t)sad_array[t] << LOG2_PRECISION;
+ if (mv_dist < bestsad) {
+ const MV this_mv = { best_full_mv->row + ss_mv[i].row,
+ best_full_mv->col + ss_mv[i].col };
+ const int64_t mv_cost =
+ vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
+ const int64_t thissad = mv_dist + lambda * mv_cost;
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = i;
+ }
}
}
}
@@ -1996,16 +2222,18 @@ static double diamond_search_sad_new(
if (is_mv_in(&x->mv_limits, &this_mv)) {
const uint8_t *const check_here = ss_os[i] + best_address;
- const double mv_dist =
- fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
- const double mv_cost =
- vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
- double thissad = mv_dist + lambda * mv_cost;
- if (thissad < bestsad) {
- bestsad = thissad;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
- best_site = i;
+ const int64_t mv_dist =
+ (int64_t)fn_ptr->sdf(what, what_stride, check_here,
+ in_what_stride)
+ << LOG2_PRECISION;
+ if (mv_dist < bestsad) {
+ const int64_t mv_cost =
+ vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
+ const int64_t thissad = mv_dist + lambda * mv_cost;
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = i;
+ }
}
}
i++;
@@ -2023,12 +2251,13 @@ static double diamond_search_sad_new(
return bestsad;
}
-void vp9_prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
- int mi_col, int rf_idx, BLOCK_SIZE bsize,
- int_mv *nb_full_mvs) {
+int vp9_prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
+ int mi_col, int rf_idx, BLOCK_SIZE bsize,
+ int_mv *nb_full_mvs) {
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };
+ int nb_full_mv_num = 0;
int i;
for (i = 0; i < NB_MVS_NUM; ++i) {
int r = dirs[i][0] * mi_height;
@@ -2038,17 +2267,15 @@ void vp9_prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
const TplDepStats *tpl_ptr =
&tpl_frame
->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c];
- int_mv *mv =
- get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row + r, mi_col + c);
if (tpl_ptr->ready[rf_idx]) {
- nb_full_mvs[i].as_mv = get_full_mv(&mv->as_mv);
- } else {
- nb_full_mvs[i].as_int = INVALID_MV;
+ int_mv *mv =
+ get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row + r, mi_col + c);
+ nb_full_mvs[nb_full_mv_num].as_mv = get_full_mv(&mv->as_mv);
+ ++nb_full_mv_num;
}
- } else {
- nb_full_mvs[i].as_int = INVALID_MV;
}
}
+ return nb_full_mv_num;
}
#endif // CONFIG_NON_GREEDY_MV
@@ -2411,22 +2638,19 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
/* do_refine: If last step (1-away) of n-step search doesn't pick the center
point as the best match, we will do a final 1-away diamond
refining search */
-double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
- MV *mvp_full, int step_param, double lambda,
- int do_refine,
- const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs, int full_mv_num,
- MV *best_mv, double *best_mv_dist,
- double *best_mv_cost) {
+int vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x, MV *mvp_full,
+ int step_param, int lambda, int do_refine,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const int_mv *nb_full_mvs, int full_mv_num,
+ MV *best_mv) {
int n, num00 = 0;
- double thissme;
- double bestsme;
+ int thissme;
+ int bestsme;
const int further_steps = MAX_MVSEARCH_STEPS - 1 - step_param;
const MV center_mv = { 0, 0 };
vpx_clear_system_state();
- bestsme = diamond_search_sad_new(
- x, &cpi->ss_cfg, mvp_full, best_mv, best_mv_dist, best_mv_cost,
- step_param, lambda, &n, fn_ptr, nb_full_mvs, full_mv_num);
+ diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, best_mv, step_param, lambda,
+ &n, fn_ptr, nb_full_mvs, full_mv_num);
bestsme = vp9_get_mvpred_var(x, best_mv, &center_mv, fn_ptr, 0);
@@ -2440,11 +2664,9 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
num00--;
} else {
MV temp_mv;
- double mv_dist;
- double mv_cost;
- thissme = diamond_search_sad_new(
- x, &cpi->ss_cfg, mvp_full, &temp_mv, &mv_dist, &mv_cost,
- step_param + n, lambda, &num00, fn_ptr, nb_full_mvs, full_mv_num);
+ diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
+ step_param + n, lambda, &num00, fn_ptr,
+ nb_full_mvs, full_mv_num);
thissme = vp9_get_mvpred_var(x, &temp_mv, &center_mv, fn_ptr, 0);
// check to see if refining search is needed.
if (num00 > further_steps - n) do_refine = 0;
@@ -2452,8 +2674,6 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
if (thissme < bestsme) {
bestsme = thissme;
*best_mv = temp_mv;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
}
}
}
@@ -2462,22 +2682,18 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
if (do_refine) {
const int search_range = 8;
MV temp_mv = *best_mv;
- double mv_dist;
- double mv_cost;
- thissme = vp9_refining_search_sad_new(x, &temp_mv, &mv_dist, &mv_cost,
- lambda, search_range, fn_ptr,
- nb_full_mvs, full_mv_num);
+ vp9_refining_search_sad_new(x, &temp_mv, lambda, search_range, fn_ptr,
+ nb_full_mvs, full_mv_num);
thissme = vp9_get_mvpred_var(x, &temp_mv, &center_mv, fn_ptr, 0);
if (thissme < bestsme) {
bestsme = thissme;
*best_mv = temp_mv;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
}
}
- bestsme = full_pixel_exhaustive_new(cpi, x, best_mv, fn_ptr, best_mv, lambda,
- nb_full_mvs, full_mv_num);
+ full_pixel_exhaustive_new(cpi, x, best_mv, fn_ptr, best_mv, lambda,
+ nb_full_mvs, full_mv_num);
+ bestsme = vp9_get_mvpred_var(x, best_mv, &center_mv, fn_ptr, 0);
return bestsme;
}
#endif // CONFIG_NON_GREEDY_MV
@@ -2605,24 +2821,27 @@ static int full_pixel_exhaustive(const VP9_COMP *const cpi,
}
#if CONFIG_NON_GREEDY_MV
-double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
- double *best_mv_dist, double *best_mv_cost,
- double lambda, int search_range,
- const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs, int full_mv_num) {
+int64_t vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
+ int lambda, int search_range,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const int_mv *nb_full_mvs,
+ int full_mv_num) {
const MACROBLOCKD *const xd = &x->e_mbd;
const MV neighbors[4] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
const struct buf_2d *const what = &x->plane[0].src;
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
const uint8_t *best_address = get_buf_from_mv(in_what, best_full_mv);
- double best_sad;
+ int64_t best_sad;
int i, j;
vpx_clear_system_state();
- *best_mv_dist =
- fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride);
- *best_mv_cost =
- vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
- best_sad = (*best_mv_dist) + lambda * (*best_mv_cost);
+ {
+ const int64_t mv_dist = (int64_t)fn_ptr->sdf(what->buf, what->stride,
+ best_address, in_what->stride)
+ << LOG2_PRECISION;
+ const int64_t mv_cost =
+ vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
+ best_sad = mv_dist + lambda * mv_cost;
+ }
for (i = 0; i < search_range; i++) {
int best_site = -1;
@@ -2642,14 +2861,12 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
for (j = 0; j < 4; ++j) {
const MV mv = { best_full_mv->row + neighbors[j].row,
best_full_mv->col + neighbors[j].col };
- const double mv_dist = sads[j];
- const double mv_cost =
+ const int64_t mv_dist = (int64_t)sads[j] << LOG2_PRECISION;
+ const int64_t mv_cost =
vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
- const double thissad = mv_dist + lambda * mv_cost;
+ const int64_t thissad = mv_dist + lambda * mv_cost;
if (thissad < best_sad) {
best_sad = thissad;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
best_site = j;
}
}
@@ -2659,16 +2876,16 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
best_full_mv->col + neighbors[j].col };
if (is_mv_in(&x->mv_limits, &mv)) {
- const double mv_dist =
- fn_ptr->sdf(what->buf, what->stride,
- get_buf_from_mv(in_what, &mv), in_what->stride);
- const double mv_cost =
+ const int64_t mv_dist =
+ (int64_t)fn_ptr->sdf(what->buf, what->stride,
+ get_buf_from_mv(in_what, &mv),
+ in_what->stride)
+ << LOG2_PRECISION;
+ const int64_t mv_cost =
vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
- const double thissad = mv_dist + lambda * mv_cost;
+ const int64_t thissad = mv_dist + lambda * mv_cost;
if (thissad < best_sad) {
best_sad = thissad;
- *best_mv_dist = mv_dist;
- *best_mv_cost = mv_cost;
best_site = j;
}
}
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h
index da93c5d44a2..9466a9ed5c4 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_mcomp.h
@@ -128,21 +128,20 @@ void vp9_set_subpel_mv_search_range(MvLimits *subpel_mv_limits,
#if CONFIG_NON_GREEDY_MV
#define NB_MVS_NUM 4
struct TplDepStats;
-double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
- double *best_mv_dist, double *best_mv_cost,
- double lambda, int search_range,
- const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs, int full_mv_num);
-
-double vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
- MV *mvp_full, int step_param, double lambda,
- int do_refine,
- const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs, int full_mv_num,
- MV *best_mv, double *best_mv_dist,
- double *best_mv_cost);
-
-double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs, int mv_num);
+int64_t vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
+ int lambda, int search_range,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const int_mv *nb_full_mvs, int full_mv_num);
+
+int vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
+ MV *mvp_full, int step_param, int lambda,
+ int do_refine,
+ const vp9_variance_fn_ptr_t *fn_ptr,
+ const int_mv *nb_full_mvs, int full_mv_num,
+ MV *best_mv);
+
+int64_t vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
+ int mv_num);
static INLINE MV get_full_mv(const MV *mv) {
MV out_mv;
out_mv.row = mv->row >> 3;
@@ -150,9 +149,9 @@ static INLINE MV get_full_mv(const MV *mv) {
return out_mv;
}
struct TplDepFrame;
-void vp9_prepare_nb_full_mvs(const struct TplDepFrame *tpl_frame, int mi_row,
- int mi_col, int rf_idx, BLOCK_SIZE bsize,
- int_mv *nb_full_mvs);
+int vp9_prepare_nb_full_mvs(const struct TplDepFrame *tpl_frame, int mi_row,
+ int mi_col, int rf_idx, BLOCK_SIZE bsize,
+ int_mv *nb_full_mvs);
static INLINE BLOCK_SIZE get_square_block_size(BLOCK_SIZE bsize) {
BLOCK_SIZE square_bsize;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c
index d6052fade85..cfcf4f7af98 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_pickmode.c
@@ -560,33 +560,29 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
// Transform skipping test in UV planes.
for (i = 1; i <= 2; i++) {
- if (cpi->oxcf.speed < 8 || x->color_sensitivity[i - 1]) {
- struct macroblock_plane *const p = &x->plane[i];
- struct macroblockd_plane *const pd = &xd->plane[i];
- const TX_SIZE uv_tx_size = get_uv_tx_size(xd->mi[0], pd);
- const BLOCK_SIZE unit_size = txsize_to_bsize[uv_tx_size];
- const BLOCK_SIZE uv_bsize = get_plane_block_size(bsize, pd);
- const int uv_bw = b_width_log2_lookup[uv_bsize];
- const int uv_bh = b_height_log2_lookup[uv_bsize];
- const int sf = (uv_bw - b_width_log2_lookup[unit_size]) +
- (uv_bh - b_height_log2_lookup[unit_size]);
- const uint32_t uv_dc_thr = pd->dequant[0] * pd->dequant[0] >> (6 - sf);
- const uint32_t uv_ac_thr = pd->dequant[1] * pd->dequant[1] >> (6 - sf);
- int j = i - 1;
-
- vp9_build_inter_predictors_sbp(xd, mi_row, mi_col, bsize, i);
- flag_preduv_computed[i - 1] = 1;
- var_uv[j] = cpi->fn_ptr[uv_bsize].vf(
- p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, &sse_uv[j]);
-
- if ((var_uv[j] < uv_ac_thr || var_uv[j] == 0) &&
- (sse_uv[j] - var_uv[j] < uv_dc_thr || sse_uv[j] == var_uv[j]))
- skip_uv[j] = 1;
- else
- break;
- } else {
- skip_uv[i - 1] = 1;
- }
+ struct macroblock_plane *const p = &x->plane[i];
+ struct macroblockd_plane *const pd = &xd->plane[i];
+ const TX_SIZE uv_tx_size = get_uv_tx_size(xd->mi[0], pd);
+ const BLOCK_SIZE unit_size = txsize_to_bsize[uv_tx_size];
+ const BLOCK_SIZE uv_bsize = get_plane_block_size(bsize, pd);
+ const int uv_bw = b_width_log2_lookup[uv_bsize];
+ const int uv_bh = b_height_log2_lookup[uv_bsize];
+ const int sf = (uv_bw - b_width_log2_lookup[unit_size]) +
+ (uv_bh - b_height_log2_lookup[unit_size]);
+ const uint32_t uv_dc_thr = pd->dequant[0] * pd->dequant[0] >> (6 - sf);
+ const uint32_t uv_ac_thr = pd->dequant[1] * pd->dequant[1] >> (6 - sf);
+ int j = i - 1;
+
+ vp9_build_inter_predictors_sbp(xd, mi_row, mi_col, bsize, i);
+ flag_preduv_computed[i - 1] = 1;
+ var_uv[j] = cpi->fn_ptr[uv_bsize].vf(
+ p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, &sse_uv[j]);
+
+ if ((var_uv[j] < uv_ac_thr || var_uv[j] == 0) &&
+ (sse_uv[j] - var_uv[j] < uv_dc_thr || sse_uv[j] == var_uv[j]))
+ skip_uv[j] = 1;
+ else
+ break;
}
// If the transform in YUV planes are skippable, the mode search checks
@@ -2558,6 +2554,10 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data,
if (!((1 << this_mode) & cpi->sf.intra_y_mode_bsize_mask[bsize]))
continue;
+ if (cpi->sf.rt_intra_dc_only_low_content && this_mode != DC_PRED &&
+ x->content_state_sb != kVeryHighSad)
+ continue;
+
if ((cpi->sf.adaptive_rd_thresh_row_mt &&
rd_less_than_thresh_row_mt(best_rdc.rdcost, mode_rd_thresh,
&rd_thresh_freq_fact[mode_index])) ||
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c
index e45030ab88b..548f2645f25 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.c
@@ -436,6 +436,10 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
rc->use_post_encode_drop = 0;
rc->ext_use_post_encode_drop = 0;
rc->arf_active_best_quality_adjustment_factor = 1.0;
+ rc->arf_increase_active_best_quality = 0;
+ rc->preserve_arf_as_gld = 0;
+ rc->preserve_next_arf_as_gld = 0;
+ rc->show_arf_as_gld = 0;
}
static int check_buffer_above_thresh(VP9_COMP *cpi, int drop_mark) {
@@ -1416,8 +1420,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index,
int active_worst_quality = cpi->twopass.active_worst_quality;
int q;
int *inter_minq;
- int arf_active_best_quality_adjustment, arf_active_best_quality_max;
- int *arfgf_high_motion_minq;
+ int arf_active_best_quality_hl;
+ int *arfgf_high_motion_minq, *arfgf_low_motion_minq;
const int boost_frame =
!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame);
@@ -1444,14 +1448,20 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index,
if (q < cq_level) q = cq_level;
}
active_best_quality = get_gf_active_quality(cpi, q, cm->bit_depth);
+ arf_active_best_quality_hl = active_best_quality;
- ASSIGN_MINQ_TABLE(cm->bit_depth, arfgf_high_motion_minq);
- arf_active_best_quality_max = arfgf_high_motion_minq[q];
- arf_active_best_quality_adjustment =
- arf_active_best_quality_max - active_best_quality;
- active_best_quality = arf_active_best_quality_max -
- (int)(arf_active_best_quality_adjustment *
- rc->arf_active_best_quality_adjustment_factor);
+ if (rc->arf_increase_active_best_quality == 1) {
+ ASSIGN_MINQ_TABLE(cm->bit_depth, arfgf_high_motion_minq);
+ arf_active_best_quality_hl = arfgf_high_motion_minq[q];
+ } else if (rc->arf_increase_active_best_quality == -1) {
+ ASSIGN_MINQ_TABLE(cm->bit_depth, arfgf_low_motion_minq);
+ arf_active_best_quality_hl = arfgf_low_motion_minq[q];
+ }
+ active_best_quality =
+ (int)((double)active_best_quality *
+ rc->arf_active_best_quality_adjustment_factor +
+ (double)arf_active_best_quality_hl *
+ (1.0 - rc->arf_active_best_quality_adjustment_factor));
// Modify best quality for second level arfs. For mode VPX_Q this
// becomes the baseline frame q.
@@ -1476,17 +1486,30 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index,
// Extension to max or min Q if undershoot or overshoot is outside
// the permitted range.
if (frame_is_intra_only(cm) || boost_frame) {
+ const int layer_depth = gf_group->layer_depth[gf_group_index];
active_best_quality -=
(cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast);
active_worst_quality += (cpi->twopass.extend_maxq / 2);
+
+ if (gf_group->rf_level[gf_group_index] == GF_ARF_LOW) {
+ assert(layer_depth > 1);
+ active_best_quality =
+ VPXMAX(active_best_quality,
+ cpi->twopass.last_qindex_of_arf_layer[layer_depth - 1]);
+ }
} else {
+ const int max_layer_depth = gf_group->max_layer_depth;
+ assert(max_layer_depth > 0);
+
active_best_quality -=
(cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast) / 2;
active_worst_quality += cpi->twopass.extend_maxq;
// For normal frames do not allow an active minq lower than the q used for
// the last boosted frame.
- active_best_quality = VPXMAX(active_best_quality, rc->last_boosted_qindex);
+ active_best_quality =
+ VPXMAX(active_best_quality,
+ cpi->twopass.last_qindex_of_arf_layer[max_layer_depth - 1]);
}
#if LIMIT_QRANGE_FOR_ALTREF_AND_KEY
@@ -1521,6 +1544,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index,
} else {
q = rc->last_boosted_qindex;
}
+ } else if (frame_is_intra_only(cm) && !rc->this_key_frame_forced) {
+ q = active_best_quality;
} else {
q = vp9_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality,
active_worst_quality);
@@ -1574,6 +1599,7 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) {
cpi->rc.is_src_frame_alt_ref = 0;
cm->show_existing_frame = 0;
+ cpi->rc.show_arf_as_gld = 0;
switch (twopass->gf_group.update_type[gf_group_index]) {
case KF_UPDATE:
cpi->refresh_last_frame = 1;
@@ -1595,6 +1621,12 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) {
cpi->refresh_golden_frame = 1;
cpi->refresh_alt_ref_frame = 0;
cpi->rc.is_src_frame_alt_ref = 1;
+ if (cpi->rc.preserve_arf_as_gld) {
+ cpi->rc.show_arf_as_gld = 1;
+ cpi->refresh_golden_frame = 0;
+ cm->show_existing_frame = 1;
+ cm->refresh_frame_context = 0;
+ }
break;
case MID_OVERLAY_UPDATE:
cpi->refresh_last_frame = 1;
@@ -1716,6 +1748,15 @@ static void update_golden_frame_stats(VP9_COMP *cpi) {
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
rc->frames_since_golden++;
+
+ if (rc->show_arf_as_gld) {
+ rc->frames_since_golden = 0;
+ // If we are not using alt ref in the up and coming group clear the arf
+ // active flag. In multi arf group case, if the index is not 0 then
+ // we are overlaying a mid group arf so should not reset the flag.
+ if (!rc->source_alt_ref_pending && (cpi->twopass.gf_group.index == 0))
+ rc->source_alt_ref_active = 0;
+ }
}
}
@@ -1767,6 +1808,9 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
RATE_CONTROL *const rc = &cpi->rc;
SVC *const svc = &cpi->svc;
const int qindex = cm->base_qindex;
+ const GF_GROUP *gf_group = &cpi->twopass.gf_group;
+ const int gf_group_index = cpi->twopass.gf_group.index;
+ const int layer_depth = gf_group->layer_depth[gf_group_index];
// Update rate control heuristics
rc->projected_frame_size = (int)(bytes_used << 3);
@@ -1821,6 +1865,15 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
(cpi->refresh_golden_frame && !rc->is_src_frame_alt_ref)))) {
rc->last_boosted_qindex = qindex;
}
+
+ if ((qindex < cpi->twopass.last_qindex_of_arf_layer[layer_depth]) ||
+ (cm->frame_type == KEY_FRAME) ||
+ (!rc->constrained_gf_group &&
+ (cpi->refresh_alt_ref_frame ||
+ (cpi->refresh_golden_frame && !rc->is_src_frame_alt_ref)))) {
+ cpi->twopass.last_qindex_of_arf_layer[layer_depth] = qindex;
+ }
+
if (frame_is_intra_only(cm)) rc->last_kf_qindex = qindex;
update_buffer_level_postencode(cpi, rc->projected_frame_size);
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h
index 2c2048edc57..1100ce7342b 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h
@@ -198,7 +198,11 @@ typedef struct {
int damped_adjustment[RATE_FACTOR_LEVELS];
double arf_active_best_quality_adjustment_factor;
- int arf_active_best_quality_adjustment_window;
+ int arf_increase_active_best_quality;
+
+ int preserve_arf_as_gld;
+ int preserve_next_arf_as_gld;
+ int show_arf_as_gld;
} RATE_CONTROL;
struct VP9_COMP;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c
index 5955451fd3a..34c74424ce0 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.c
@@ -57,6 +57,30 @@ void vp9_rd_cost_init(RD_COST *rd_cost) {
rd_cost->rdcost = 0;
}
+int64_t vp9_calculate_rd_cost(int mult, int div, int rate, int64_t dist) {
+ assert(mult >= 0);
+ assert(div > 0);
+ if (rate >= 0 && dist >= 0) {
+ return RDCOST(mult, div, rate, dist);
+ }
+ if (rate >= 0 && dist < 0) {
+ return RDCOST_NEG_D(mult, div, rate, -dist);
+ }
+ if (rate < 0 && dist >= 0) {
+ return RDCOST_NEG_R(mult, div, -rate, dist);
+ }
+ return -RDCOST(mult, div, -rate, -dist);
+}
+
+void vp9_rd_cost_update(int mult, int div, RD_COST *rd_cost) {
+ if (rd_cost->rate < INT_MAX && rd_cost->dist < INT64_MAX) {
+ rd_cost->rdcost =
+ vp9_calculate_rd_cost(mult, div, rd_cost->rate, rd_cost->dist);
+ } else {
+ vp9_rd_cost_reset(rd_cost);
+ }
+}
+
// The baseline rd thresholds for breaking out of the rd loop for
// certain modes are assumed to be based on 8x8 blocks.
// This table is used to correct for block size.
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h
index f948f5ba2f1..df6ea9094c4 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rd.h
@@ -28,6 +28,11 @@ extern "C" {
#define RDCOST(RM, DM, R, D) \
ROUND_POWER_OF_TWO(((int64_t)(R)) * (RM), VP9_PROB_COST_SHIFT) + ((D) << (DM))
+#define RDCOST_NEG_R(RM, DM, R, D) \
+ ((D) << (DM)) - ROUND_POWER_OF_TWO(((int64_t)(R)) * (RM), VP9_PROB_COST_SHIFT)
+#define RDCOST_NEG_D(RM, DM, R, D) \
+ ROUND_POWER_OF_TWO(((int64_t)(R)) * (RM), VP9_PROB_COST_SHIFT) - ((D) << (DM))
+
#define QIDX_SKIP_THRESH 115
#define MV_COST_WEIGHT 108
@@ -131,6 +136,10 @@ typedef struct RD_COST {
void vp9_rd_cost_reset(RD_COST *rd_cost);
// Initialize the rate distortion cost values to zero.
void vp9_rd_cost_init(RD_COST *rd_cost);
+// It supports negative rate and dist, which is different from RDCOST().
+int64_t vp9_calculate_rd_cost(int mult, int div, int rate, int64_t dist);
+// Update the cost value based on its rate and distortion.
+void vp9_rd_cost_update(int mult, int div, RD_COST *rd_cost);
struct TileInfo;
struct TileDataEnc;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c
index 6c7c4e0f85c..65b94357dd8 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.c
@@ -31,6 +31,9 @@
#include "vp9/common/vp9_scan.h"
#include "vp9/common/vp9_seg_common.h"
+#if !CONFIG_REALTIME_ONLY
+#include "vp9/encoder/vp9_aq_variance.h"
+#endif
#include "vp9/encoder/vp9_cost.h"
#include "vp9/encoder/vp9_encodemb.h"
#include "vp9/encoder/vp9_encodemv.h"
@@ -40,7 +43,6 @@
#include "vp9/encoder/vp9_ratectrl.h"
#include "vp9/encoder/vp9_rd.h"
#include "vp9/encoder/vp9_rdopt.h"
-#include "vp9/encoder/vp9_aq_variance.h"
#define LAST_FRAME_MODE_MASK \
((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | (1 << INTRA_FRAME))
@@ -81,6 +83,8 @@ struct rdcost_block_args {
};
#define LAST_NEW_MV_INDEX 6
+
+#if !CONFIG_REALTIME_ONLY
static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{ NEARESTMV, { LAST_FRAME, NONE } },
{ NEARESTMV, { ALTREF_FRAME, NONE } },
@@ -128,6 +132,7 @@ static const REF_DEFINITION vp9_ref_order[MAX_REFS] = {
{ { ALTREF_FRAME, NONE } }, { { LAST_FRAME, ALTREF_FRAME } },
{ { GOLDEN_FRAME, ALTREF_FRAME } }, { { INTRA_FRAME, NONE } },
};
+#endif // !CONFIG_REALTIME_ONLY
static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, int m, int n,
int min_plane, int max_plane) {
@@ -154,6 +159,7 @@ static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, int m, int n,
}
}
+#if !CONFIG_REALTIME_ONLY
static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize, MACROBLOCK *x,
MACROBLOCKD *xd, int *out_rate_sum,
int64_t *out_dist_sum, int *skip_txfm_sb,
@@ -278,6 +284,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize, MACROBLOCK *x,
*out_rate_sum = (int)rate_sum;
*out_dist_sum = dist_sum << VP9_DIST_SCALE_LOG2;
}
+#endif // !CONFIG_REALTIME_ONLY
#if CONFIG_VP9_HIGHBITDEPTH
int64_t vp9_highbd_block_error_c(const tran_low_t *coeff,
@@ -1517,6 +1524,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
return best_rd;
}
+#if !CONFIG_REALTIME_ONLY
static int64_t rd_sbuv_dcpred(const VP9_COMP *cpi, MACROBLOCK *x, int *rate,
int *rate_tokenonly, int64_t *distortion,
int *skippable, BLOCK_SIZE bsize) {
@@ -1728,6 +1736,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi, MACROBLOCK *x,
return RDCOST(x->rdmult, x->rddiv, *labelyrate, *distortion);
}
+#endif // !CONFIG_REALTIME_ONLY
typedef struct {
int eobs;
@@ -1755,6 +1764,7 @@ typedef struct {
int mvthresh;
} BEST_SEG_INFO;
+#if !CONFIG_REALTIME_ONLY
static INLINE int mv_check_bounds(const MvLimits *mv_limits, const MV *mv) {
return (mv->row >> 3) < mv_limits->row_min ||
(mv->row >> 3) > mv_limits->row_max ||
@@ -2484,20 +2494,18 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
const int ph = num_4x4_blocks_high_lookup[bsize] << 2;
MV pred_mv[3];
+ int bestsme = INT_MAX;
#if CONFIG_NON_GREEDY_MV
- double mv_dist = 0;
- double mv_cost = 0;
- double lambda = (pw * ph) / 4;
- double bestsme;
- int_mv nb_full_mvs[NB_MVS_NUM];
- const int nb_full_mv_num = NB_MVS_NUM;
int gf_group_idx = cpi->twopass.gf_group.index;
int gf_rf_idx = ref_frame_to_gf_rf_idx(ref);
BLOCK_SIZE square_bsize = get_square_block_size(bsize);
- vp9_prepare_nb_full_mvs(&cpi->tpl_stats[gf_group_idx], mi_row, mi_col,
- gf_rf_idx, square_bsize, nb_full_mvs);
+ int_mv nb_full_mvs[NB_MVS_NUM];
+ const int nb_full_mv_num =
+ vp9_prepare_nb_full_mvs(&cpi->tpl_stats[gf_group_idx], mi_row, mi_col,
+ gf_rf_idx, square_bsize, nb_full_mvs);
+ const int lambda = (pw * ph) / 4;
+ assert(pw * ph == lambda << 2);
#else // CONFIG_NON_GREEDY_MV
- int bestsme = INT_MAX;
int sadpb = x->sadperbit16;
#endif // CONFIG_NON_GREEDY_MV
@@ -2571,9 +2579,9 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
mvp_full.row >>= 3;
#if CONFIG_NON_GREEDY_MV
- bestsme = vp9_full_pixel_diamond_new(
- cpi, x, &mvp_full, step_param, lambda, 1, &cpi->fn_ptr[bsize],
- nb_full_mvs, nb_full_mv_num, &tmp_mv->as_mv, &mv_dist, &mv_cost);
+ bestsme = vp9_full_pixel_diamond_new(cpi, x, &mvp_full, step_param, lambda, 1,
+ &cpi->fn_ptr[bsize], nb_full_mvs,
+ nb_full_mv_num, &tmp_mv->as_mv);
#else // CONFIG_NON_GREEDY_MV
bestsme = vp9_full_pixel_search(
cpi, x, bsize, &mvp_full, step_param, cpi->sf.mv.search_method, sadpb,
@@ -2583,11 +2591,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
if (cpi->sf.enhanced_full_pixel_motion_search) {
int i;
for (i = 0; i < 3; ++i) {
-#if CONFIG_NON_GREEDY_MV
- double this_me;
-#else // CONFIG_NON_GREEDY_MV
int this_me;
-#endif // CONFIG_NON_GREEDY_MV
MV this_mv;
int diff_row;
int diff_col;
@@ -2614,8 +2618,8 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
#if CONFIG_NON_GREEDY_MV
this_me = vp9_full_pixel_diamond_new(
cpi, x, &mvp_full, VPXMAX(step_param, MAX_MVSEARCH_STEPS - step),
- lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, nb_full_mv_num, &this_mv,
- &mv_dist, &mv_cost);
+ lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, nb_full_mv_num,
+ &this_mv);
#else // CONFIG_NON_GREEDY_MV
this_me = vp9_full_pixel_search(
cpi, x, bsize, &mvp_full,
@@ -3075,6 +3079,7 @@ static int64_t handle_inter_mode(
restore_dst_buf(xd, orig_dst, orig_dst_stride);
return 0; // The rate-distortion cost will be re-calculated by caller.
}
+#endif // !CONFIG_REALTIME_ONLY
void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
@@ -3128,6 +3133,7 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost,
rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
}
+#if !CONFIG_REALTIME_ONLY
// This function is designed to apply a bias or adjustment to an rd value based
// on the relative variance of the source and reconstruction.
#define LOW_VAR_THRESH 250
@@ -3217,6 +3223,7 @@ static void rd_variance_adjustment(VP9_COMP *cpi, MACROBLOCK *x,
(void)xd;
}
+#endif // !CONFIG_REALTIME_ONLY
// Do we have an internal image edge (e.g. formatting bars).
int vp9_internal_image_edge(VP9_COMP *cpi) {
@@ -3287,6 +3294,7 @@ int vp9_active_edge_sb(VP9_COMP *cpi, int mi_row, int mi_col) {
vp9_active_v_edge(cpi, mi_col, MI_BLOCK_SIZE);
}
+#if !CONFIG_REALTIME_ONLY
void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, TileDataEnc *tile_data,
MACROBLOCK *x, int mi_row, int mi_col,
RD_COST *rd_cost, BLOCK_SIZE bsize,
@@ -3779,7 +3787,6 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, TileDataEnc *tile_data,
}
}
}
-
// Apply an adjustment to the rd value based on the similarity of the
// source variance and reconstructed variance.
rd_variance_adjustment(cpi, x, bsize, &this_rd, recon, ref_frame,
@@ -4748,3 +4755,4 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, TileDataEnc *tile_data,
store_coding_context(x, ctx, best_ref_index, best_pred_diff, best_filter_diff,
0);
}
+#endif // !CONFIG_REALTIME_ONLY
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h
index 8b810bc4758..e1147ff9438 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_rdopt.h
@@ -29,6 +29,7 @@ void vp9_rd_pick_intra_mode_sb(struct VP9_COMP *cpi, struct macroblock *x,
struct RD_COST *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, int64_t best_rd);
+#if !CONFIG_REALTIME_ONLY
void vp9_rd_pick_inter_mode_sb(struct VP9_COMP *cpi,
struct TileDataEnc *tile_data,
struct macroblock *x, int mi_row, int mi_col,
@@ -39,18 +40,21 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(
struct VP9_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x,
struct RD_COST *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far);
+#endif
int vp9_internal_image_edge(struct VP9_COMP *cpi);
int vp9_active_h_edge(struct VP9_COMP *cpi, int mi_row, int mi_step);
int vp9_active_v_edge(struct VP9_COMP *cpi, int mi_col, int mi_step);
int vp9_active_edge_sb(struct VP9_COMP *cpi, int mi_row, int mi_col);
+#if !CONFIG_REALTIME_ONLY
void vp9_rd_pick_inter_mode_sub8x8(struct VP9_COMP *cpi,
struct TileDataEnc *tile_data,
struct macroblock *x, int mi_row, int mi_col,
struct RD_COST *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far);
+#endif
#ifdef __cplusplus
} // extern "C"
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c
index 64881a5f91f..cccafd85cd0 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.c
@@ -20,6 +20,7 @@ static MESH_PATTERN best_quality_mesh_pattern[MAX_MESH_STEP] = {
{ 64, 4 }, { 28, 2 }, { 15, 1 }, { 7, 1 }
};
+#if !CONFIG_REALTIME_ONLY
// Define 3 mesh density levels to control the number of searches.
#define MESH_DENSITY_LEVELS 3
static MESH_PATTERN
@@ -385,6 +386,7 @@ static void set_good_speed_feature_framesize_independent(VP9_COMP *cpi,
sf->simple_model_rd_from_var = 1;
}
}
+#endif // !CONFIG_REALTIME_ONLY
static void set_rt_speed_feature_framesize_dependent(VP9_COMP *cpi,
SPEED_FEATURES *sf,
@@ -454,6 +456,7 @@ static void set_rt_speed_feature_framesize_independent(
sf->variance_part_thresh_mult = 1;
sf->cb_pred_filter_search = 0;
sf->force_smooth_interpol = 0;
+ sf->rt_intra_dc_only_low_content = 0;
if (speed >= 1) {
sf->allow_txfm_domain_distortion = 1;
@@ -738,12 +741,7 @@ static void set_rt_speed_feature_framesize_independent(
sf->nonrd_use_ml_partition = 0;
#endif
if (content == VP9E_CONTENT_SCREEN) sf->mv.subpel_force_stop = HALF_PEL;
- // Only keep INTRA_DC mode for speed 8.
- if (!is_keyframe) {
- int i = 0;
- for (i = 0; i < BLOCK_SIZES; ++i)
- sf->intra_y_mode_bsize_mask[i] = INTRA_DC;
- }
+ sf->rt_intra_dc_only_low_content = 1;
if (!cpi->use_svc && cpi->oxcf.rc_mode == VPX_CBR &&
content != VP9E_CONTENT_SCREEN) {
// More aggressive short circuit for speed 8.
@@ -769,6 +767,12 @@ static void set_rt_speed_feature_framesize_independent(
}
if (speed >= 9) {
+ // Only keep INTRA_DC mode for speed 9.
+ if (!is_keyframe) {
+ int i = 0;
+ for (i = 0; i < BLOCK_SIZES; ++i)
+ sf->intra_y_mode_bsize_mask[i] = INTRA_DC;
+ }
sf->cb_pred_filter_search = 1;
sf->mv.enable_adaptive_subpel_force_stop = 1;
sf->mv.adapt_subpel_force_stop.mv_thresh = 1;
@@ -832,11 +836,12 @@ void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi, int speed) {
sf->rd_ml_partition.search_early_termination = 0;
sf->rd_ml_partition.search_breakout = 0;
- if (oxcf->mode == REALTIME) {
+ if (oxcf->mode == REALTIME)
set_rt_speed_feature_framesize_dependent(cpi, sf, speed);
- } else if (oxcf->mode == GOOD) {
+#if !CONFIG_REALTIME_ONLY
+ else if (oxcf->mode == GOOD)
set_good_speed_feature_framesize_dependent(cpi, sf, speed);
- }
+#endif
if (sf->disable_split_mask == DISABLE_ALL_SPLIT) {
sf->adaptive_pred_interp_filter = 0;
@@ -866,7 +871,9 @@ void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi, int speed) {
void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) {
SPEED_FEATURES *const sf = &cpi->sf;
+#if !CONFIG_REALTIME_ONLY
VP9_COMMON *const cm = &cpi->common;
+#endif
MACROBLOCK *const x = &cpi->td.mb;
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
int i;
@@ -979,8 +986,10 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) {
if (oxcf->mode == REALTIME)
set_rt_speed_feature_framesize_independent(cpi, sf, speed, oxcf->content);
+#if !CONFIG_REALTIME_ONLY
else if (oxcf->mode == GOOD)
set_good_speed_feature_framesize_independent(cpi, cm, sf, speed);
+#endif
cpi->diamond_search_sad = vp9_diamond_search_sad;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h
index eb06281990a..ca284ded821 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_speed_features.h
@@ -608,6 +608,10 @@ typedef struct SPEED_FEATURES {
// Force subpel motion filter to always use SMOOTH_FILTER.
int force_smooth_interpol;
+
+ // 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;
} SPEED_FEATURES;
struct VP9_COMP;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c b/chromium/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c
index 56588285670..45e03f2def3 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c
@@ -15,6 +15,7 @@
#include "vpx/vpx_encoder.h"
#include "vpx_ports/vpx_once.h"
#include "vpx_ports/system_state.h"
+#include "vpx_util/vpx_timestamp.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "./vpx_version.h"
#include "vp9/encoder/vp9_encoder.h"
@@ -94,6 +95,9 @@ struct vpx_codec_alg_priv {
vpx_codec_priv_t base;
vpx_codec_enc_cfg_t cfg;
struct vp9_extracfg extra_cfg;
+ vpx_rational64_t timestamp_ratio;
+ vpx_codec_pts_t pts_offset;
+ unsigned char pts_offset_initialized;
VP9EncoderConfig oxcf;
VP9_COMP *cpi;
unsigned char *cx_data;
@@ -151,6 +155,22 @@ static vpx_codec_err_t update_error_state(
if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \
} while (0)
+#if defined(_MSC_VER)
+#define COMPILE_TIME_ASSERT(boolexp) \
+ do { \
+ char compile_time_assert[(boolexp) ? 1 : -1]; \
+ (void)compile_time_assert; \
+ } while (0)
+#else // !_MSC_VER
+#define COMPILE_TIME_ASSERT(boolexp) \
+ do { \
+ struct { \
+ unsigned int compile_time_assert : (boolexp) ? 1 : -1; \
+ } compile_time_assert; \
+ (void)compile_time_assert; \
+ } while (0)
+#endif // _MSC_VER
+
static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
const vpx_codec_enc_cfg_t *cfg,
const struct vp9_extracfg *extra_cfg) {
@@ -914,6 +934,12 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
res = validate_config(priv, &priv->cfg, &priv->extra_cfg);
if (res == VPX_CODEC_OK) {
+ priv->pts_offset_initialized = 0;
+ priv->timestamp_ratio.den = priv->cfg.g_timebase.den;
+ priv->timestamp_ratio.num = (int64_t)priv->cfg.g_timebase.num;
+ priv->timestamp_ratio.num *= TICKS_PER_SEC;
+ reduce_ratio(&priv->timestamp_ratio);
+
set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg);
#if CONFIG_VP9_HIGHBITDEPTH
priv->oxcf.use_highbitdepth =
@@ -950,12 +976,14 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
switch (ctx->cfg.g_pass) {
case VPX_RC_ONE_PASS:
if (deadline > 0) {
- const vpx_codec_enc_cfg_t *const cfg = &ctx->cfg;
-
// Convert duration parameter from stream timebase to microseconds.
- const uint64_t duration_us = (uint64_t)duration * 1000000 *
- (uint64_t)cfg->g_timebase.num /
- (uint64_t)cfg->g_timebase.den;
+ uint64_t duration_us;
+
+ COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 &&
+ (TICKS_PER_SEC % 1000000) == 0);
+
+ duration_us = duration * (uint64_t)ctx->timestamp_ratio.num /
+ (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000));
// If the deadline is more that the duration this frame is to be shown,
// use good quality mode. Otherwise use realtime mode.
@@ -1039,15 +1067,16 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
return index_sz;
}
-static int64_t timebase_units_to_ticks(const vpx_rational_t *timebase,
+static int64_t timebase_units_to_ticks(const vpx_rational64_t *timestamp_ratio,
int64_t n) {
- return n * TICKS_PER_SEC * timebase->num / timebase->den;
+ return n * timestamp_ratio->num / timestamp_ratio->den;
}
-static int64_t ticks_to_timebase_units(const vpx_rational_t *timebase,
+static int64_t ticks_to_timebase_units(const vpx_rational64_t *timestamp_ratio,
int64_t n) {
- const int64_t round = (int64_t)TICKS_PER_SEC * timebase->num / 2 - 1;
- return (n * timebase->den + round) / timebase->num / TICKS_PER_SEC;
+ int64_t round = timestamp_ratio->num / 2;
+ if (round > 0) --round;
+ return (n * timestamp_ratio->den + round) / timestamp_ratio->num;
}
static vpx_codec_frame_flags_t get_frame_pkt_flags(const VP9_COMP *cpi,
@@ -1070,14 +1099,15 @@ static vpx_codec_frame_flags_t get_frame_pkt_flags(const VP9_COMP *cpi,
const size_t kMinCompressedSize = 8192;
static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
const vpx_image_t *img,
- vpx_codec_pts_t pts,
+ vpx_codec_pts_t pts_val,
unsigned long duration,
vpx_enc_frame_flags_t enc_flags,
unsigned long deadline) {
volatile vpx_codec_err_t res = VPX_CODEC_OK;
volatile vpx_enc_frame_flags_t flags = enc_flags;
+ volatile vpx_codec_pts_t pts = pts_val;
VP9_COMP *const cpi = ctx->cpi;
- const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
+ const vpx_rational64_t *const timestamp_ratio = &ctx->timestamp_ratio;
size_t data_sz;
if (cpi == NULL) return VPX_CODEC_INVALID_PARAM;
@@ -1111,6 +1141,12 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
}
}
+ if (!ctx->pts_offset_initialized) {
+ ctx->pts_offset = pts;
+ ctx->pts_offset_initialized = 1;
+ }
+ pts -= ctx->pts_offset;
+
pick_quickcompress_mode(ctx, duration, deadline);
vpx_codec_pkt_list_init(&ctx->pkt_list);
@@ -1143,13 +1179,13 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
if (res == VPX_CODEC_OK) {
unsigned int lib_flags = 0;
YV12_BUFFER_CONFIG sd;
- int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts);
+ int64_t dst_time_stamp = timebase_units_to_ticks(timestamp_ratio, pts);
int64_t dst_end_time_stamp =
- timebase_units_to_ticks(timebase, pts + duration);
+ timebase_units_to_ticks(timestamp_ratio, pts + duration);
size_t size, cx_data_sz;
unsigned char *cx_data;
- cpi->svc.timebase_fac = timebase_units_to_ticks(timebase, 1);
+ cpi->svc.timebase_fac = timebase_units_to_ticks(timestamp_ratio, 1);
cpi->svc.time_stamp_superframe = dst_time_stamp;
// Set up internal flags
@@ -1212,9 +1248,10 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
if (ctx->output_cx_pkt_cb.output_cx_pkt) {
pkt.kind = VPX_CODEC_CX_FRAME_PKT;
pkt.data.frame.pts =
- ticks_to_timebase_units(timebase, dst_time_stamp);
+ ticks_to_timebase_units(timestamp_ratio, dst_time_stamp) +
+ ctx->pts_offset;
pkt.data.frame.duration = (unsigned long)ticks_to_timebase_units(
- timebase, dst_end_time_stamp - dst_time_stamp);
+ timestamp_ratio, dst_end_time_stamp - dst_time_stamp);
pkt.data.frame.flags = get_frame_pkt_flags(cpi, lib_flags);
pkt.data.frame.buf = ctx->pending_cx_data;
pkt.data.frame.sz = size;
@@ -1230,9 +1267,11 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
// Add the frame packet to the list of returned packets.
pkt.kind = VPX_CODEC_CX_FRAME_PKT;
- pkt.data.frame.pts = ticks_to_timebase_units(timebase, dst_time_stamp);
+ pkt.data.frame.pts =
+ ticks_to_timebase_units(timestamp_ratio, dst_time_stamp) +
+ ctx->pts_offset;
pkt.data.frame.duration = (unsigned long)ticks_to_timebase_units(
- timebase, dst_end_time_stamp - dst_time_stamp);
+ timestamp_ratio, dst_end_time_stamp - dst_time_stamp);
pkt.data.frame.flags = get_frame_pkt_flags(cpi, lib_flags);
pkt.data.frame.width[cpi->svc.spatial_layer_id] = cpi->common.width;
pkt.data.frame.height[cpi->svc.spatial_layer_id] = cpi->common.height;
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/vp9cx.mk b/chromium/third_party/libvpx/source/libvpx/vp9/vp9cx.mk
index 1b276bfb1c7..736ff017064 100644
--- a/chromium/third_party/libvpx/source/libvpx/vp9/vp9cx.mk
+++ b/chromium/third_party/libvpx/source/libvpx/vp9/vp9cx.mk
@@ -154,5 +154,13 @@ VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_temporal_filter.c
VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/x86/temporal_filter_sse4.c
VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/x86/temporal_filter_constants.h
VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/x86/highbd_temporal_filter_sse4.c
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_alt_ref_aq.h
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_alt_ref_aq.c
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_variance.c
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_variance.h
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_360.c
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_360.h
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_complexity.c
+VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_aq_complexity.h
VP9_CX_SRCS-yes := $(filter-out $(VP9_CX_SRCS_REMOVE-yes),$(VP9_CX_SRCS-yes))
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx/exports_spatial_svc b/chromium/third_party/libvpx/source/libvpx/vpx/exports_spatial_svc
deleted file mode 100644
index 9d60cb6353f..00000000000
--- a/chromium/third_party/libvpx/source/libvpx/vpx/exports_spatial_svc
+++ /dev/null
@@ -1,5 +0,0 @@
-text vpx_svc_dump_statistics
-text vpx_svc_encode
-text vpx_svc_init
-text vpx_svc_release
-text vpx_svc_set_options
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c b/chromium/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c
index 3385c22c0a2..c227ee902d9 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c
+++ b/chromium/third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c
@@ -82,6 +82,9 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(
res = VPX_CODEC_INCAPABLE;
else {
int i;
+#if CONFIG_MULTI_RES_ENCODING
+ int mem_loc_owned = 0;
+#endif
void *mem_loc = NULL;
if (iface->enc.mr_get_mem_loc == NULL) return VPX_CODEC_INCAPABLE;
@@ -101,12 +104,6 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(
mr_cfg.mr_down_sampling_factor.num = dsf->num;
mr_cfg.mr_down_sampling_factor.den = dsf->den;
- /* Force Key-frame synchronization. Namely, encoder at higher
- * resolution always use the same frame_type chosen by the
- * lowest-resolution encoder.
- */
- if (mr_cfg.mr_encoder_id) cfg->kf_mode = VPX_KF_DISABLED;
-
ctx->iface = iface;
ctx->name = iface->name;
ctx->priv = NULL;
@@ -129,13 +126,17 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(
i--;
}
#if CONFIG_MULTI_RES_ENCODING
- assert(mem_loc);
- free(((LOWER_RES_FRAME_INFO *)mem_loc)->mb_info);
- free(mem_loc);
+ if (!mem_loc_owned) {
+ assert(mem_loc);
+ free(((LOWER_RES_FRAME_INFO *)mem_loc)->mb_info);
+ free(mem_loc);
+ }
#endif
return SAVE_STATUS(ctx, res);
}
-
+#if CONFIG_MULTI_RES_ENCODING
+ mem_loc_owned = 1;
+#endif
ctx++;
cfg++;
dsf++;
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h
index 43340e48d9a..752308160dc 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/arm/transpose_neon.h
@@ -138,8 +138,8 @@ static INLINE void transpose_s16_4x4q(int16x8_t *a0, int16x8_t *a1) {
vtrnq_s32(vreinterpretq_s32_s16(*a0), vreinterpretq_s32_s16(*a1));
// Swap 64 bit elements resulting in:
- // c0.val[0]: 00 01 20 21 02 03 22 23
- // c0.val[1]: 10 11 30 31 12 13 32 33
+ // c0: 00 01 20 21 02 03 22 23
+ // c1: 10 11 30 31 12 13 32 33
const int32x4_t c0 =
vcombine_s32(vget_low_s32(b0.val[0]), vget_low_s32(b0.val[1]));
@@ -169,8 +169,8 @@ static INLINE void transpose_u16_4x4q(uint16x8_t *a0, uint16x8_t *a1) {
vtrnq_u32(vreinterpretq_u32_u16(*a0), vreinterpretq_u32_u16(*a1));
// Swap 64 bit elements resulting in:
- // c0.val[0]: 00 01 20 21 02 03 22 23
- // c0.val[1]: 10 11 30 31 12 13 32 33
+ // c0: 00 01 20 21 02 03 22 23
+ // c1: 10 11 30 31 12 13 32 33
const uint32x4_t c0 =
vcombine_u32(vget_low_u32(b0.val[0]), vget_low_u32(b0.val[1]));
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c
index 6273460f190..a4c8322ff2e 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c
@@ -35,6 +35,8 @@ void vpx_v_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
}
}
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
static const uint32x4_t mask4 = { 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
void vpx_h_predictor_4x4_vsx(uint8_t *dst, ptrdiff_t stride,
@@ -87,6 +89,7 @@ void vpx_h_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
dst += stride;
vec_vsx_st(xxpermdi(v7, vec_vsx_ld(0, dst), 1), 0, dst);
}
+#endif
void vpx_h_predictor_16x16_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
@@ -233,6 +236,8 @@ void vpx_h_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
H_PREDICTOR_32(v15_1);
}
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
void vpx_tm_predictor_4x4_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
const int16x8_t tl = unpack_to_s16_h(vec_splat(vec_vsx_ld(-1, above), 0));
@@ -311,6 +316,7 @@ void vpx_tm_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
val = vec_sub(vec_add(vec_splat(l, 7), a), tl);
vec_vsx_st(vec_packsu(val, tmp), 0, dst);
}
+#endif
static void tm_predictor_16x8(uint8_t *dst, const ptrdiff_t stride, int16x8_t l,
int16x8_t ah, int16x8_t al, int16x8_t tl) {
@@ -547,6 +553,8 @@ void vpx_dc_top_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
dc_fill_predictor_32x32(dst, stride, avg32(above));
}
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
static uint8x16_t dc_avg8(const uint8_t *above, const uint8_t *left) {
const uint8x16_t a0 = vec_vsx_ld(0, above);
const uint8x16_t l0 = vec_vsx_ld(0, left);
@@ -559,6 +567,7 @@ static uint8x16_t dc_avg8(const uint8_t *above, const uint8_t *left) {
return vec_splat(vec_pack(vec_pack(avg, vec_splat_u32(0)), vec_splat_u16(0)),
3);
}
+#endif
static uint8x16_t dc_avg16(const uint8_t *above, const uint8_t *left) {
const uint8x16_t a0 = vec_vsx_ld(0, above);
@@ -573,10 +582,13 @@ static uint8x16_t dc_avg16(const uint8_t *above, const uint8_t *left) {
3);
}
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
void vpx_dc_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
dc_fill_predictor_8x8(dst, stride, dc_avg8(above, left));
}
+#endif
void vpx_dc_predictor_16x16_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
@@ -615,6 +627,8 @@ static uint8x16_t avg3(const uint8x16_t a, const uint8x16_t b,
static const uint8x16_t sl1 = { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8,
0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10 };
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
void vpx_d45_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
const uint8x16_t af = vec_vsx_ld(0, above);
@@ -633,6 +647,7 @@ void vpx_d45_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
row = vec_perm(row, above_right, sl1);
}
}
+#endif
void vpx_d45_predictor_16x16_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
@@ -674,6 +689,8 @@ void vpx_d45_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
}
}
+// TODO(crbug.com/webm/1522): Fix test failures.
+#if 0
void vpx_d63_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
const uint8x16_t af = vec_vsx_ld(0, above);
@@ -696,6 +713,7 @@ void vpx_d63_predictor_8x8_vsx(uint8_t *dst, ptrdiff_t stride,
row1 = vec_perm(row1, above_right, sl1);
}
}
+#endif
void vpx_d63_predictor_16x16_vsx(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/sad.c b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/sad.c
index 873ddca0938..769322019e9 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/sad.c
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/sad.c
@@ -83,6 +83,7 @@ sadMxNx4D(32, 64)
// 32x32
sadMxN(32, 32)
+sadMxNxK(32, 32, 8)
sadMxNx4D(32, 32)
// 32x16
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/variance.h b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/variance.h
index 6d0e1b8a6b3..bbf3e8f463f 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/variance.h
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/variance.h
@@ -76,6 +76,7 @@ typedef struct vp9_variance_vtable {
vpx_subpixvariance_fn_t svf;
vpx_subp_avg_variance_fn_t svaf;
vpx_sad_multi_d_fn_t sdx4df;
+ vpx_sad_multi_fn_t sdx8f;
} vp9_variance_fn_ptr_t;
#endif // CONFIG_VP9
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk
index 916a99017d1..f013fa59220 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp.mk
@@ -47,13 +47,11 @@ endif
# intra predictions
DSP_SRCS-yes += intrapred.c
-DSP_SRCS-$(HAVE_SSE) += x86/intrapred_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/intrapred_sse2.asm
DSP_SRCS-$(HAVE_SSSE3) += x86/intrapred_ssse3.asm
DSP_SRCS-$(HAVE_VSX) += ppc/intrapred_vsx.c
ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes)
-DSP_SRCS-$(HAVE_SSE) += x86/highbd_intrapred_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/highbd_intrapred_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/highbd_intrapred_intrin_sse2.c
DSP_SRCS-$(HAVE_SSSE3) += x86/highbd_intrapred_intrin_ssse3.c
@@ -167,8 +165,8 @@ DSP_SRCS-$(HAVE_VSX) += ppc/vpx_convolve_vsx.c
# loop filters
DSP_SRCS-yes += loopfilter.c
-DSP_SRCS-$(ARCH_X86)$(ARCH_X86_64) += x86/loopfilter_sse2.c
-DSP_SRCS-$(HAVE_AVX2) += x86/loopfilter_avx2.c
+DSP_SRCS-$(HAVE_SSE2) += x86/loopfilter_sse2.c
+DSP_SRCS-$(HAVE_AVX2) += x86/loopfilter_avx2.c
ifeq ($(HAVE_NEON_ASM),yes)
DSP_SRCS-yes += arm/loopfilter_16_neon$(ASM)
@@ -354,8 +352,6 @@ DSP_SRCS-$(HAVE_AVX2) += x86/sad4d_avx2.c
DSP_SRCS-$(HAVE_AVX2) += x86/sad_avx2.c
DSP_SRCS-$(HAVE_AVX512) += x86/sad4d_avx512.c
-DSP_SRCS-$(HAVE_SSE) += x86/sad4d_sse2.asm
-DSP_SRCS-$(HAVE_SSE) += x86/sad_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/sad4d_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/sad_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/subtract_sse2.asm
@@ -383,7 +379,6 @@ DSP_SRCS-$(HAVE_MSA) += mips/sub_pixel_variance_msa.c
DSP_SRCS-$(HAVE_MMI) += mips/variance_mmi.c
-DSP_SRCS-$(HAVE_SSE) += x86/variance_sse2.c
DSP_SRCS-$(HAVE_SSE2) += x86/avg_pred_sse2.c
DSP_SRCS-$(HAVE_SSE2) += x86/variance_sse2.c # Contains SSE2 and SSSE3
DSP_SRCS-$(HAVE_AVX2) += x86/variance_avx2.c
@@ -393,7 +388,6 @@ ifeq ($(ARCH_X86_64),yes)
DSP_SRCS-$(HAVE_SSE2) += x86/ssim_opt_x86_64.asm
endif # ARCH_X86_64
-DSP_SRCS-$(HAVE_SSE) += x86/subpel_variance_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/subpel_variance_sse2.asm # Contains SSE2 and SSSE3
ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes)
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h
index f1fcf2df5ff..2de4495465e 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_common.h
@@ -57,6 +57,10 @@ static INLINE double fclamp(double value, double low, double high) {
return value < low ? low : (value > high ? high : value);
}
+static INLINE int64_t lclamp(int64_t value, int64_t low, int64_t high) {
+ return value < low ? low : (value > high ? high : value);
+}
+
static INLINE uint16_t clip_pixel_highbd(int val, int bd) {
switch (bd) {
case 8:
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl
index 363154a7750..fd7eefdad05 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl
@@ -51,7 +51,8 @@ specialize qw/vpx_d63_predictor_4x4 ssse3/;
add_proto qw/void vpx_d63e_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_h_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_h_predictor_4x4 neon dspr2 msa sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_h_predictor_4x4 neon dspr2 msa sse2/;
add_proto qw/void vpx_he_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
@@ -69,7 +70,8 @@ specialize qw/vpx_v_predictor_4x4 neon msa sse2/;
add_proto qw/void vpx_ve_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_tm_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_tm_predictor_4x4 neon dspr2 msa sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_tm_predictor_4x4 neon dspr2 msa sse2/;
add_proto qw/void vpx_dc_predictor_4x4/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_predictor_4x4 dspr2 msa neon sse2/;
@@ -87,13 +89,16 @@ add_proto qw/void vpx_d207_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, cons
specialize qw/vpx_d207_predictor_8x8 ssse3/;
add_proto qw/void vpx_d45_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_d45_predictor_8x8 neon sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_d45_predictor_8x8 neon sse2/;
add_proto qw/void vpx_d63_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_d63_predictor_8x8 ssse3 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_d63_predictor_8x8 ssse3/;
add_proto qw/void vpx_h_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_h_predictor_8x8 neon dspr2 msa sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_h_predictor_8x8 neon dspr2 msa sse2/;
add_proto qw/void vpx_d117_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
@@ -107,10 +112,12 @@ add_proto qw/void vpx_v_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const u
specialize qw/vpx_v_predictor_8x8 neon msa sse2/;
add_proto qw/void vpx_tm_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_tm_predictor_8x8 neon dspr2 msa sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_tm_predictor_8x8 neon dspr2 msa sse2/;
add_proto qw/void vpx_dc_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_dc_predictor_8x8 dspr2 neon msa sse2 vsx/;
+# TODO(crbug.com/webm/1522): Re-enable vsx implementation.
+specialize qw/vpx_dc_predictor_8x8 dspr2 neon msa sse2/;
add_proto qw/void vpx_dc_top_predictor_8x8/, "uint8_t *dst, ptrdiff_t stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_top_predictor_8x8 neon msa sse2/;
@@ -886,6 +893,9 @@ add_proto qw/void vpx_sad4x4x3/, "const uint8_t *src_ptr, int src_stride, const
specialize qw/vpx_sad4x4x3 sse3 msa mmi/;
# Blocks of 8
+add_proto qw/void vpx_sad32x32x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
+specialize qw/vpx_sad32x32x8 avx2/;
+
add_proto qw/void vpx_sad16x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x16x8 sse4_1 msa mmi/;
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c
index b18fecf709c..a5c4f8c5371 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c
@@ -11,8 +11,8 @@
#include "./vpx_dsp_rtcd.h"
#include "vpx/vpx_integer.h"
-static INLINE void calc_final(const __m256i *const sums /*[4]*/,
- uint32_t sad_array[4]) {
+static INLINE void calc_final_4(const __m256i *const sums /*[4]*/,
+ uint32_t *sad_array) {
const __m256i t0 = _mm256_hadd_epi32(sums[0], sums[1]);
const __m256i t1 = _mm256_hadd_epi32(sums[2], sums[3]);
const __m256i t2 = _mm256_hadd_epi32(t0, t1);
@@ -66,7 +66,64 @@ void vpx_sad32x32x4d_avx2(const uint8_t *src_ptr, int src_stride,
refs[3] += ref_stride;
}
- calc_final(sums, sad_array);
+ calc_final_4(sums, sad_array);
+}
+
+void vpx_sad32x32x8_avx2(const uint8_t *src_ptr, int src_stride,
+ const uint8_t *ref_ptr, int ref_stride,
+ uint32_t *sad_array) {
+ int i;
+ __m256i sums[8];
+
+ sums[0] = _mm256_setzero_si256();
+ sums[1] = _mm256_setzero_si256();
+ sums[2] = _mm256_setzero_si256();
+ sums[3] = _mm256_setzero_si256();
+ sums[4] = _mm256_setzero_si256();
+ sums[5] = _mm256_setzero_si256();
+ sums[6] = _mm256_setzero_si256();
+ sums[7] = _mm256_setzero_si256();
+
+ for (i = 0; i < 32; i++) {
+ __m256i r[8];
+
+ // load src and all ref[]
+ const __m256i s = _mm256_load_si256((const __m256i *)src_ptr);
+ r[0] = _mm256_loadu_si256((const __m256i *)&ref_ptr[0]);
+ r[1] = _mm256_loadu_si256((const __m256i *)&ref_ptr[1]);
+ r[2] = _mm256_loadu_si256((const __m256i *)&ref_ptr[2]);
+ r[3] = _mm256_loadu_si256((const __m256i *)&ref_ptr[3]);
+ r[4] = _mm256_loadu_si256((const __m256i *)&ref_ptr[4]);
+ r[5] = _mm256_loadu_si256((const __m256i *)&ref_ptr[5]);
+ r[6] = _mm256_loadu_si256((const __m256i *)&ref_ptr[6]);
+ r[7] = _mm256_loadu_si256((const __m256i *)&ref_ptr[7]);
+
+ // sum of the absolute differences between every ref[] to src
+ r[0] = _mm256_sad_epu8(r[0], s);
+ r[1] = _mm256_sad_epu8(r[1], s);
+ r[2] = _mm256_sad_epu8(r[2], s);
+ r[3] = _mm256_sad_epu8(r[3], s);
+ r[4] = _mm256_sad_epu8(r[4], s);
+ r[5] = _mm256_sad_epu8(r[5], s);
+ r[6] = _mm256_sad_epu8(r[6], s);
+ r[7] = _mm256_sad_epu8(r[7], s);
+
+ // sum every ref[]
+ sums[0] = _mm256_add_epi32(sums[0], r[0]);
+ sums[1] = _mm256_add_epi32(sums[1], r[1]);
+ sums[2] = _mm256_add_epi32(sums[2], r[2]);
+ sums[3] = _mm256_add_epi32(sums[3], r[3]);
+ sums[4] = _mm256_add_epi32(sums[4], r[4]);
+ sums[5] = _mm256_add_epi32(sums[5], r[5]);
+ sums[6] = _mm256_add_epi32(sums[6], r[6]);
+ sums[7] = _mm256_add_epi32(sums[7], r[7]);
+
+ src_ptr += src_stride;
+ ref_ptr += ref_stride;
+ }
+
+ calc_final_4(sums, sad_array);
+ calc_final_4(sums + 4, sad_array + 4);
}
void vpx_sad64x64x4d_avx2(const uint8_t *src_ptr, int src_stride,
@@ -126,5 +183,5 @@ void vpx_sad64x64x4d_avx2(const uint8_t *src_ptr, int src_stride,
refs[3] += ref_stride;
}
- calc_final(sums, sad_array);
+ calc_final_4(sums, sad_array);
}
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h b/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h
new file mode 100644
index 00000000000..c210de5e537
--- /dev/null
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 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_UTIL_VPX_TIMESTAMP_H_
+#define VPX_VPX_UTIL_VPX_TIMESTAMP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+// Rational Number with an int64 numerator
+typedef struct vpx_rational64 {
+ int64_t num; // fraction numerator
+ int den; // fraction denominator
+} vpx_rational64_t; // alias for struct vpx_rational64_t
+
+static INLINE int gcd(int64_t a, int b) {
+ int r; // remainder
+ while (b > 0) {
+ r = (int)(a % b);
+ a = b;
+ b = r;
+ }
+
+ return (int)a;
+}
+
+static INLINE void reduce_ratio(vpx_rational64_t *ratio) {
+ const int denom = gcd(ratio->num, ratio->den);
+ ratio->num /= denom;
+ ratio->den /= denom;
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif // __cplusplus
+
+#endif // VPX_VPX_UTIL_VPX_TIMESTAMP_H_
diff --git a/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk b/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk
index c97f3f32276..11627149569 100644
--- a/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk
+++ b/chromium/third_party/libvpx/source/libvpx/vpx_util/vpx_util.mk
@@ -15,5 +15,6 @@ UTIL_SRCS-yes += vpx_thread.h
UTIL_SRCS-yes += endian_inl.h
UTIL_SRCS-yes += vpx_write_yuv_frame.h
UTIL_SRCS-yes += vpx_write_yuv_frame.c
+UTIL_SRCS-yes += vpx_timestamp.h
UTIL_SRCS-$(or $(CONFIG_BITSTREAM_DEBUG),$(CONFIG_MISMATCH_DEBUG)) += vpx_debug_util.h
UTIL_SRCS-$(or $(CONFIG_BITSTREAM_DEBUG),$(CONFIG_MISMATCH_DEBUG)) += vpx_debug_util.c