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 --test-decode=fatal \
132 --output="${output}" \
135 if [ ! -e "${output}" ]; then
136 elog "Output file does not exist."
143 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
144 [ "$(webm_io_available)" = "yes" ]; then
145 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
147 --width="${YUV_RAW_INPUT_WIDTH}" \
148 --height="${YUV_RAW_INPUT_HEIGHT}" \
149 --limit="${TEST_FRAMES}" \
150 --test-decode=fatal \
151 --output="${output}" \
154 if [ ! -e "${output}" ]; then
155 elog "Output file does not exist."
161 vpxenc_vp9_ivf_lossless() {
162 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
163 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
165 --width="${YUV_RAW_INPUT_WIDTH}" \
166 --height="${YUV_RAW_INPUT_HEIGHT}" \
167 --limit="${TEST_FRAMES}" \
169 --output="${output}" \
171 --test-decode=fatal \
174 if [ ! -e "${output}" ]; then
175 elog "Output file does not exist."
181 vpxenc_vp9_ivf_minq0_maxq0() {
182 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
183 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
185 --width="${YUV_RAW_INPUT_WIDTH}" \
186 --height="${YUV_RAW_INPUT_HEIGHT}" \
187 --limit="${TEST_FRAMES}" \
189 --output="${output}" \
192 --test-decode=fatal \
195 if [ ! -e "${output}" ]; then
196 elog "Output file does not exist."
202 vpxenc_tests="vpxenc_vp8_ivf
204 vpxenc_vp8_ivf_piped_input
207 vpxenc_vp9_ivf_lossless
208 vpxenc_vp9_ivf_minq0_maxq0"
210 run_tests vpxenc_verify_environment "${vpxenc_tests}"