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 elog "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}" - \
57 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
58 # the directory containing vpxenc. $1 one is used as the input file path and
59 # shifted away. All remaining parameters are passed through to vpxenc.
61 local readonly encoder="$(vpx_tool_path vpxenc)"
62 local readonly input="${1}"
64 eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" \
70 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
71 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
73 --width="${YUV_RAW_INPUT_WIDTH}" \
74 --height="${YUV_RAW_INPUT_HEIGHT}" \
75 --limit="${TEST_FRAMES}" \
77 --output="${output}" \
80 if [ ! -e "${output}" ]; then
81 elog "Output file does not exist."
88 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
89 [ "$(webm_io_available)" = "yes" ]; then
90 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
92 --width="${YUV_RAW_INPUT_WIDTH}" \
93 --height="${YUV_RAW_INPUT_HEIGHT}" \
94 --limit="${TEST_FRAMES}" \
95 --output="${output}" \
98 if [ ! -e "${output}" ]; then
99 elog "Output file does not exist."
105 vpxenc_vp8_webm_2pass() {
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}" \
117 if [ ! -e "${output}" ]; then
118 elog "Output file does not exist."
124 vpxenc_vp8_webm_lag10_frames20() {
125 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
126 [ "$(webm_io_available)" = "yes" ]; then
127 local readonly lag_total_frames=20
128 local readonly lag_frames=10
129 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_lag10_frames20.webm"
131 --width="${YUV_RAW_INPUT_WIDTH}" \
132 --height="${YUV_RAW_INPUT_HEIGHT}" \
133 --limit="${lag_total_frames}" \
134 --lag-in-frames="${lag_frames}" \
135 --output="${output}" \
140 if [ ! -e "${output}" ]; then
141 elog "Output file does not exist."
147 vpxenc_vp8_ivf_piped_input() {
148 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
149 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
150 cat "${YUV_RAW_INPUT}" \
151 | vpxenc --codec=vp8 \
152 --width="${YUV_RAW_INPUT_WIDTH}" \
153 --height="${YUV_RAW_INPUT_HEIGHT}" \
154 --limit="${TEST_FRAMES}" \
156 --output="${output}" \
159 if [ ! -e "${output}" ]; then
160 elog "Output file does not exist."
167 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
168 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
170 --width="${YUV_RAW_INPUT_WIDTH}" \
171 --height="${YUV_RAW_INPUT_HEIGHT}" \
172 --limit="${TEST_FRAMES}" \
174 --output="${output}" \
177 if [ ! -e "${output}" ]; then
178 elog "Output file does not exist."
185 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
186 [ "$(webm_io_available)" = "yes" ]; then
187 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
189 --width="${YUV_RAW_INPUT_WIDTH}" \
190 --height="${YUV_RAW_INPUT_HEIGHT}" \
191 --limit="${TEST_FRAMES}" \
192 --output="${output}" \
195 if [ ! -e "${output}" ]; then
196 elog "Output file does not exist."
202 vpxenc_vp9_webm_2pass() {
203 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
204 [ "$(webm_io_available)" = "yes" ]; then
205 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
207 --width="${YUV_RAW_INPUT_WIDTH}" \
208 --height="${YUV_RAW_INPUT_HEIGHT}" \
209 --limit="${TEST_FRAMES}" \
210 --test-decode=fatal \
211 --output="${output}" \
215 if [ ! -e "${output}" ]; then
216 elog "Output file does not exist."
222 vpxenc_vp9_ivf_lossless() {
223 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
224 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
226 --width="${YUV_RAW_INPUT_WIDTH}" \
227 --height="${YUV_RAW_INPUT_HEIGHT}" \
228 --limit="${TEST_FRAMES}" \
230 --output="${output}" \
234 if [ ! -e "${output}" ]; then
235 elog "Output file does not exist."
241 vpxenc_vp9_ivf_minq0_maxq0() {
242 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
243 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
245 --width="${YUV_RAW_INPUT_WIDTH}" \
246 --height="${YUV_RAW_INPUT_HEIGHT}" \
247 --limit="${TEST_FRAMES}" \
249 --output="${output}" \
254 if [ ! -e "${output}" ]; then
255 elog "Output file does not exist."
261 vpxenc_vp9_webm_lag10_frames20() {
262 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
263 [ "$(webm_io_available)" = "yes" ]; then
264 local readonly lag_total_frames=20
265 local readonly lag_frames=10
266 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lag10_frames20.webm"
268 --width="${YUV_RAW_INPUT_WIDTH}" \
269 --height="${YUV_RAW_INPUT_HEIGHT}" \
270 --limit="${lag_total_frames}" \
271 --lag-in-frames="${lag_frames}" \
272 --output="${output}" \
273 --test-decode=fatal \
278 if [ ! -e "${output}" ]; then
279 elog "Output file does not exist."
285 vpxenc_tests="vpxenc_vp8_ivf
287 vpxenc_vp8_webm_2pass
288 vpxenc_vp8_webm_lag10_frames20
289 vpxenc_vp8_ivf_piped_input
292 vpxenc_vp9_webm_2pass
293 vpxenc_vp9_ivf_lossless
294 vpxenc_vp9_ivf_minq0_maxq0
295 vpxenc_vp9_webm_lag10_frames20"
297 run_tests vpxenc_verify_environment "${vpxenc_tests}"