3 ## Copyright (c) 2014 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 tests vpxenc using hantro_collage_w352h288.yuv as input. To add
12 ## new tests to this file, do the following:
13 ## 1. Write a shell function (this is your test).
14 ## 2. Add the function to vpxenc_tests (on a new line).
16 . $(dirname $0)/tools_common.sh
18 readonly TEST_FRAMES=10
20 # Environment check: Make sure input is available.
21 vpxenc_verify_environment() {
22 if [ ! -e "${YUV_RAW_INPUT}" ]; then
23 echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
28 vpxenc_can_encode_vp8() {
29 if [ "$(vpxenc_available)" = "yes" ] && \
30 [ "$(vp8_encode_available)" = "yes" ]; then
35 vpxenc_can_encode_vp9() {
36 if [ "$(vpxenc_available)" = "yes" ] && \
37 [ "$(vp9_encode_available)" = "yes" ]; then
42 # Echoes yes to stdout when vpxenc exists according to vpx_tool_available().
44 [ -n "$(vpx_tool_available vpxenc)" ] && echo yes
47 # Wrapper function for running vpxenc with pipe input. Requires that
48 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the
49 # input file path and shifted away. All remaining parameters are passed through
52 local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}"
53 local readonly input="$1"
55 cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - "$@" ${devnull}
58 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
59 # the directory containing vpxenc. $1 one is used as the input file path and
60 # shifted away. All remaining parameters are passed through to vpxenc.
62 local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}"
63 local readonly input="${1}"
65 eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" "$@" ${devnull}
69 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
70 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
72 --width="${YUV_RAW_INPUT_WIDTH}" \
73 --height="${YUV_RAW_INPUT_HEIGHT}" \
74 --limit="${TEST_FRAMES}" \
76 --output="${output}" \
79 if [ ! -e "${output}" ]; then
80 elog "Output file does not exist."
86 vpxenc_vp8_ivf_piped_input() {
87 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
88 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
89 cat "${YUV_RAW_INPUT}" \
90 | vpxenc --codec=vp8 \
91 --width="${YUV_RAW_INPUT_WIDTH}" \
92 --height="${YUV_RAW_INPUT_HEIGHT}" \
93 --limit="${TEST_FRAMES}" \
95 --output="${output}" \
98 if [ ! -e "${output}" ]; then
99 elog "Output file does not exist."
106 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
107 [ "$(webm_io_available)" = "yes" ]; then
108 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
110 --width="${YUV_RAW_INPUT_WIDTH}" \
111 --height="${YUV_RAW_INPUT_HEIGHT}" \
112 --limit="${TEST_FRAMES}" \
113 --output="${output}" \
116 if [ ! -e "${output}" ]; then
117 elog "Output file does not exist."
124 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
125 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
127 --width="${YUV_RAW_INPUT_WIDTH}" \
128 --height="${YUV_RAW_INPUT_HEIGHT}" \
129 --limit="${TEST_FRAMES}" \
131 --output="${output}" \
134 if [ ! -e "${output}" ]; then
135 elog "Output file does not exist."
142 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
143 [ "$(webm_io_available)" = "yes" ]; then
144 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
146 --width="${YUV_RAW_INPUT_WIDTH}" \
147 --height="${YUV_RAW_INPUT_HEIGHT}" \
148 --limit="${TEST_FRAMES}" \
149 --output="${output}" \
152 if [ ! -e "${output}" ]; then
153 elog "Output file does not exist."
159 vpxenc_vp9_ivf_lossless() {
160 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
161 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
163 --width="${YUV_RAW_INPUT_WIDTH}" \
164 --height="${YUV_RAW_INPUT_HEIGHT}" \
165 --limit="${TEST_FRAMES}" \
167 --output="${output}" \
169 --test-decode=fatal \
172 if [ ! -e "${output}" ]; then
173 elog "Output file does not exist."
179 vpxenc_vp9_ivf_minq0_maxq0() {
180 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
181 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
183 --width="${YUV_RAW_INPUT_WIDTH}" \
184 --height="${YUV_RAW_INPUT_HEIGHT}" \
185 --limit="${TEST_FRAMES}" \
187 --output="${output}" \
190 --test-decode=fatal \
193 if [ ! -e "${output}" ]; then
194 elog "Output file does not exist."
200 vpxenc_tests="vpxenc_vp8_ivf
202 vpxenc_vp8_ivf_piped_input
205 vpxenc_vp9_ivf_lossless
206 vpxenc_vp9_ivf_minq0_maxq0"
208 run_tests vpxenc_verify_environment "${vpxenc_tests}"