3 ## Copyright (c) 2016 The WebM project authors. All Rights Reserved.
5 ## Use of this source code is governed by a BSD-style license
6 ## that can be found in the LICENSE file in the root of the source
7 ## tree. An additional intellectual property rights grant can be found
8 ## in the file PATENTS. All contributing project authors may
9 ## be found in the AUTHORS file in the root of the source tree.
11 ## This file performs a stress test. It runs (STRESS_ONEPASS_MAX_JOBS,
12 ## default=5) one, (STRESS_TWOPASS_MAX_JOBS, default=5) two pass &
13 ## (STRESS_RT_MAX_JOBS, default=5) encodes and (STRESS_<codec>_DECODE_MAX_JOBS,
14 ## default=30) decodes in parallel.
16 . $(dirname $0)/tools_common.sh
18 YUV="${LIBVPX_TEST_DATA_PATH}/niklas_1280_720_30.yuv"
19 VP8="${LIBVPX_TEST_DATA_PATH}/tos_vp8.webm"
20 VP9="${LIBVPX_TEST_DATA_PATH}/vp90-2-sintel_1920x818_tile_1x4_fpm_2279kbps.webm"
21 DATA_URL="https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/"
22 SHA1_FILE="$(dirname $0)/test-data.sha1"
24 # Set sha1sum to proper sha program (sha1sum, shasum, sha1). This code is
25 # cribbed from libs.mk.
26 [ -x "$(which sha1sum)" ] && sha1sum=sha1sum
27 [ -x "$(which shasum)" ] && sha1sum=shasum
28 [ -x "$(which sha1)" ] && sha1sum=sha1
30 # Download a file from the url and check its sha1sum.
31 download_and_check_file() {
32 # Get the file from the file path.
33 local root="${1#${LIBVPX_TEST_DATA_PATH}/}"
35 # Download the file using curl. Trap to insure non partial file.
36 (trap "rm -f $1" INT TERM \
37 && eval "curl --retry 1 -L -o $1 ${DATA_URL}${root} ${devnull}")
39 # Check the sha1 sum of the file.
40 if [ -n "${sha1sum}" ]; then
42 grep ${root} ${SHA1_FILE} \
43 | (cd ${LIBVPX_TEST_DATA_PATH}; ${sha1sum} -c);
47 # Environment check: Make sure input is available.
48 stress_verify_environment() {
49 if [ ! -e "${SHA1_FILE}" ] ; then
50 echo "Missing ${SHA1_FILE}"
53 for file in "${YUV}" "${VP8}" "${VP9}"; do
54 if [ ! -e "${file}" ] ; then
55 download_and_check_file "${file}" || return 1
58 if [ ! -e "${YUV}" ] || [ ! -e "${VP8}" ] || [ ! -e "${VP9}" ] ; then
59 elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
62 if [ -z "$(vpx_tool_path vpxenc)" ]; then
63 elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent."
66 if [ -z "$(vpx_tool_path vpxdec)" ]; then
67 elog "vpxdec not found. It must exist in LIBVPX_BIN_PATH or its parent."
72 # This function runs tests on libvpx that run multiple encodes and decodes
73 # in parallel in hopes of catching synchronization and/or threading issues.
75 local decoder="$(vpx_tool_path vpxdec)"
76 local encoder="$(vpx_tool_path vpxenc)"
79 local decode_count="$3"
83 local rt_max_jobs=${STRESS_RT_MAX_JOBS:-5}
84 local onepass_max_jobs=${STRESS_ONEPASS_MAX_JOBS:-5}
85 local twopass_max_jobs=${STRESS_TWOPASS_MAX_JOBS:-5}
87 # Enable job control, so we can run multiple processes.
90 # Start $onepass_max_jobs encode jobs in parallel.
91 for i in $(seq ${onepass_max_jobs}); do
92 bitrate=$(($i * 20 + 300))
93 eval "${VPX_TEST_PREFIX}" "${encoder}" "--codec=${codec} -w 1280 -h 720" \
94 "${YUV}" "-t ${threads} --limit=150 --test-decode=fatal --passes=1" \
95 "--target-bitrate=${bitrate} -o ${VPX_TEST_OUTPUT_DIR}/${i}.1pass.webm" \
96 "${enc_args}" ${devnull} &
100 # Start $twopass_max_jobs encode jobs in parallel.
101 for i in $(seq ${twopass_max_jobs}); do
102 bitrate=$(($i * 20 + 300))
103 eval "${VPX_TEST_PREFIX}" "${encoder}" "--codec=${codec} -w 1280 -h 720" \
104 "${YUV}" "-t ${threads} --limit=150 --test-decode=fatal --passes=2" \
105 "--target-bitrate=${bitrate} -o ${VPX_TEST_OUTPUT_DIR}/${i}.2pass.webm" \
106 "${enc_args}" ${devnull} &
110 # Start $rt_max_jobs rt encode jobs in parallel.
111 for i in $(seq ${rt_max_jobs}); do
112 bitrate=$(($i * 20 + 300))
113 eval "${VPX_TEST_PREFIX}" "${encoder}" "--codec=${codec} -w 1280 -h 720" \
114 "${YUV}" "-t ${threads} --limit=150 --test-decode=fatal " \
115 "--target-bitrate=${bitrate} --lag-in-frames=0 --error-resilient=1" \
116 "--kf-min-dist=3000 --kf-max-dist=3000 --cpu-used=-6 --static-thresh=1" \
117 "--end-usage=cbr --min-q=2 --max-q=56 --undershoot-pct=100" \
118 "--overshoot-pct=15 --buf-sz=1000 --buf-initial-sz=500" \
119 "--buf-optimal-sz=600 --max-intra-rate=900 --resize-allowed=0" \
120 "--drop-frame=0 --passes=1 --rt --noise-sensitivity=4" \
121 "-o ${VPX_TEST_OUTPUT_DIR}/${i}.rt.webm" ${devnull} &
125 # Start $decode_count decode jobs in parallel.
126 for i in $(seq "${decode_count}"); do
127 eval "${decoder}" "-t ${threads}" "${webm}" "--noblit" ${devnull} &
131 # Wait for all parallel jobs to finish.
133 for job in "${pids}"; do
134 wait $job || fail=$(($fail + 1))
140 local vp8_max_jobs=${STRESS_VP8_DECODE_MAX_JOBS:-40}
141 if [ "$(vp8_decode_available)" = "yes" -a \
142 "$(vp8_encode_available)" = "yes" ]; then
143 stress vp8 "${VP8}" "${vp8_max_jobs}" 4
147 vp8_stress_test_token_parititions() {
148 local vp8_max_jobs=${STRESS_VP8_DECODE_MAX_JOBS:-40}
149 if [ "$(vp8_decode_available)" = "yes" -a \
150 "$(vp8_encode_available)" = "yes" ]; then
151 for threads in 2 4 8; do
152 for token_partitions in 1 2 3; do
153 stress vp8 "${VP8}" "${vp8_max_jobs}" ${threads} \
154 "--token-parts=$token_partitions"
161 local vp9_max_jobs=${STRESS_VP9_DECODE_MAX_JOBS:-25}
163 if [ "$(vp9_decode_available)" = "yes" -a \
164 "$(vp9_encode_available)" = "yes" ]; then
165 stress vp9 "${VP9}" "${vp9_max_jobs}" "$@"
170 for threads in 4 8 64; do
171 vp9_stress "$threads" "--row-mt=0"
175 vp9_stress_test_row_mt() {
176 for threads in 4 8 64; do
177 vp9_stress "$threads" "--row-mt=1"
181 run_tests stress_verify_environment \
182 "vp8_stress_test vp8_stress_test_token_parititions
183 vp9_stress_test vp9_stress_test_row_mt"