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 [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
27 if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
28 elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
29 elog "LIBVPX_TEST_DATA_PATH."
33 if [ -z "$(vpx_tool_path vpxenc)" ]; then
34 elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent."
39 vpxenc_can_encode_vp8() {
40 if [ "$(vp8_encode_available)" = "yes" ]; then
45 vpxenc_can_encode_vp9() {
46 if [ "$(vp9_encode_available)" = "yes" ]; then
51 # Echo vpxenc command line parameters allowing use of
52 # hantro_collage_w352h288.yuv as input.
53 yuv_input_hantro_collage() {
54 echo ""${YUV_RAW_INPUT}"
55 --width="${YUV_RAW_INPUT_WIDTH}"
56 --height="${YUV_RAW_INPUT_HEIGHT}""
59 y4m_input_non_square_par() {
60 echo ""${Y4M_NOSQ_PAR_INPUT}""
63 # Echo default vpxenc real time encoding params. $1 is the codec, which defaults
64 # to vp8 if unspecified.
66 local readonly codec="${1:-vp8}"
67 echo "--codec=${codec}
89 # Wrapper function for running vpxenc with pipe input. Requires that
90 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the
91 # input file path and shifted away. All remaining parameters are passed through
94 local readonly encoder="$(vpx_tool_path vpxenc)"
95 local readonly input="$1"
97 cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - \
102 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
103 # the directory containing vpxenc. $1 one is used as the input file path and
104 # shifted away. All remaining parameters are passed through to vpxenc.
106 local readonly encoder="$(vpx_tool_path vpxenc)"
107 local readonly input="$1"
109 eval "${VPX_TEST_PREFIX}" "${encoder}" "${input}" \
110 --test-decode=fatal \
115 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
116 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
117 vpxenc $(yuv_input_hantro_collage) \
119 --limit="${TEST_FRAMES}" \
123 if [ ! -e "${output}" ]; then
124 elog "Output file does not exist."
131 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
132 [ "$(webm_io_available)" = "yes" ]; then
133 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
134 vpxenc $(yuv_input_hantro_collage) \
136 --limit="${TEST_FRAMES}" \
139 if [ ! -e "${output}" ]; then
140 elog "Output file does not exist."
146 vpxenc_vp8_webm_rt() {
147 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
148 [ "$(webm_io_available)" = "yes" ]; then
149 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_rt.webm"
150 vpxenc $(yuv_input_hantro_collage) \
151 $(vpxenc_rt_params vp8) \
153 if [ ! -e "${output}" ]; then
154 elog "Output file does not exist."
160 vpxenc_vp8_webm_2pass() {
161 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
162 [ "$(webm_io_available)" = "yes" ]; then
163 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
164 vpxenc $(yuv_input_hantro_collage) \
166 --limit="${TEST_FRAMES}" \
167 --output="${output}" \
170 if [ ! -e "${output}" ]; then
171 elog "Output file does not exist."
177 vpxenc_vp8_webm_lag10_frames20() {
178 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
179 [ "$(webm_io_available)" = "yes" ]; then
180 local readonly lag_total_frames=20
181 local readonly lag_frames=10
182 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_lag10_frames20.webm"
183 vpxenc $(yuv_input_hantro_collage) \
185 --limit="${lag_total_frames}" \
186 --lag-in-frames="${lag_frames}" \
187 --output="${output}" \
191 if [ ! -e "${output}" ]; then
192 elog "Output file does not exist."
198 vpxenc_vp8_ivf_piped_input() {
199 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
200 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
201 vpxenc_pipe $(yuv_input_hantro_collage) \
203 --limit="${TEST_FRAMES}" \
207 if [ ! -e "${output}" ]; then
208 elog "Output file does not exist."
215 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
216 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
217 vpxenc $(yuv_input_hantro_collage) \
219 --limit="${TEST_FRAMES}" \
223 if [ ! -e "${output}" ]; then
224 elog "Output file does not exist."
231 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
232 [ "$(webm_io_available)" = "yes" ]; then
233 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
234 vpxenc $(yuv_input_hantro_collage) \
236 --limit="${TEST_FRAMES}" \
239 if [ ! -e "${output}" ]; then
240 elog "Output file does not exist."
246 vpxenc_vp9_webm_rt() {
247 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
248 [ "$(webm_io_available)" = "yes" ]; then
249 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_rt.webm"
250 vpxenc $(yuv_input_hantro_collage) \
251 $(vpxenc_rt_params vp9) \
254 if [ ! -e "${output}" ]; then
255 elog "Output file does not exist."
261 vpxenc_vp9_webm_2pass() {
262 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
263 [ "$(webm_io_available)" = "yes" ]; then
264 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
265 vpxenc $(yuv_input_hantro_collage) \
267 --limit="${TEST_FRAMES}" \
268 --output="${output}" \
271 if [ ! -e "${output}" ]; then
272 elog "Output file does not exist."
278 vpxenc_vp9_ivf_lossless() {
279 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
280 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
281 vpxenc $(yuv_input_hantro_collage) \
283 --limit="${TEST_FRAMES}" \
285 --output="${output}" \
288 if [ ! -e "${output}" ]; then
289 elog "Output file does not exist."
295 vpxenc_vp9_ivf_minq0_maxq0() {
296 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
297 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
298 vpxenc $(yuv_input_hantro_collage) \
300 --limit="${TEST_FRAMES}" \
302 --output="${output}" \
306 if [ ! -e "${output}" ]; then
307 elog "Output file does not exist."
313 vpxenc_vp9_webm_lag10_frames20() {
314 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
315 [ "$(webm_io_available)" = "yes" ]; then
316 local readonly lag_total_frames=20
317 local readonly lag_frames=10
318 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lag10_frames20.webm"
319 vpxenc $(yuv_input_hantro_collage) \
321 --limit="${lag_total_frames}" \
322 --lag-in-frames="${lag_frames}" \
323 --output="${output}" \
327 if [ ! -e "${output}" ]; then
328 elog "Output file does not exist."
334 # TODO(fgalligan): Test that DisplayWidth is different than video width.
335 vpxenc_vp9_webm_non_square_par() {
336 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
337 [ "$(webm_io_available)" = "yes" ]; then
338 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_non_square_par.webm"
339 vpxenc $(y4m_input_non_square_par) \
341 --limit="${TEST_FRAMES}" \
344 if [ ! -e "${output}" ]; then
345 elog "Output file does not exist."
351 vpxenc_tests="vpxenc_vp8_ivf
354 vpxenc_vp8_webm_2pass
355 vpxenc_vp8_webm_lag10_frames20
356 vpxenc_vp8_ivf_piped_input
360 vpxenc_vp9_webm_2pass
361 vpxenc_vp9_ivf_lossless
362 vpxenc_vp9_ivf_minq0_maxq0
363 vpxenc_vp9_webm_lag10_frames20
364 vpxenc_vp9_webm_non_square_par"
366 run_tests vpxenc_verify_environment "${vpxenc_tests}"