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."
26 if [ -z "$(vpx_tool_path vpxenc)" ]; then
27 elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent."
32 vpxenc_can_encode_vp8() {
33 if [ "$(vp8_encode_available)" = "yes" ]; then
38 vpxenc_can_encode_vp9() {
39 if [ "$(vp9_encode_available)" = "yes" ]; then
44 # Wrapper function for running vpxenc with pipe input. Requires that
45 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the
46 # input file path and shifted away. All remaining parameters are passed through
49 local readonly encoder="$(vpx_tool_path vpxenc)"
50 local readonly input="$1"
52 cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - "$@" ${devnull}
55 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
56 # the directory containing vpxenc. $1 one is used as the input file path and
57 # shifted away. All remaining parameters are passed through to vpxenc.
59 local readonly encoder="$(vpx_tool_path vpxenc)"
60 local readonly input="${1}"
62 eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" "$@" ${devnull}
66 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
67 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
69 --width="${YUV_RAW_INPUT_WIDTH}" \
70 --height="${YUV_RAW_INPUT_HEIGHT}" \
71 --limit="${TEST_FRAMES}" \
73 --output="${output}" \
76 if [ ! -e "${output}" ]; then
77 elog "Output file does not exist."
83 vpxenc_vp8_ivf_piped_input() {
84 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
85 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
86 cat "${YUV_RAW_INPUT}" \
87 | vpxenc --codec=vp8 \
88 --width="${YUV_RAW_INPUT_WIDTH}" \
89 --height="${YUV_RAW_INPUT_HEIGHT}" \
90 --limit="${TEST_FRAMES}" \
92 --output="${output}" \
95 if [ ! -e "${output}" ]; then
96 elog "Output file does not exist."
103 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
104 [ "$(webm_io_available)" = "yes" ]; then
105 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
107 --width="${YUV_RAW_INPUT_WIDTH}" \
108 --height="${YUV_RAW_INPUT_HEIGHT}" \
109 --limit="${TEST_FRAMES}" \
110 --output="${output}" \
113 if [ ! -e "${output}" ]; then
114 elog "Output file does not exist."
121 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
122 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
124 --width="${YUV_RAW_INPUT_WIDTH}" \
125 --height="${YUV_RAW_INPUT_HEIGHT}" \
126 --limit="${TEST_FRAMES}" \
128 --test-decode=fatal \
129 --output="${output}" \
132 if [ ! -e "${output}" ]; then
133 elog "Output file does not exist."
140 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
141 [ "$(webm_io_available)" = "yes" ]; then
142 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
144 --width="${YUV_RAW_INPUT_WIDTH}" \
145 --height="${YUV_RAW_INPUT_HEIGHT}" \
146 --limit="${TEST_FRAMES}" \
147 --test-decode=fatal \
148 --output="${output}" \
151 if [ ! -e "${output}" ]; then
152 elog "Output file does not exist."
158 vpxenc_vp9_ivf_lossless() {
159 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
160 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
162 --width="${YUV_RAW_INPUT_WIDTH}" \
163 --height="${YUV_RAW_INPUT_HEIGHT}" \
164 --limit="${TEST_FRAMES}" \
166 --output="${output}" \
168 --test-decode=fatal \
171 if [ ! -e "${output}" ]; then
172 elog "Output file does not exist."
178 vpxenc_vp9_ivf_minq0_maxq0() {
179 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
180 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
182 --width="${YUV_RAW_INPUT_WIDTH}" \
183 --height="${YUV_RAW_INPUT_HEIGHT}" \
184 --limit="${TEST_FRAMES}" \
186 --output="${output}" \
189 --test-decode=fatal \
192 if [ ! -e "${output}" ]; then
193 elog "Output file does not exist."
199 vpxenc_tests="vpxenc_vp8_ivf
201 vpxenc_vp8_ivf_piped_input
204 vpxenc_vp9_ivf_lossless
205 vpxenc_vp9_ivf_minq0_maxq0"
207 run_tests vpxenc_verify_environment "${vpxenc_tests}"