blob: 2eb4ad973231a65a3c12128b20d9ecef2299f3ee [file] [log] [blame]
Yaowu Xuf883b422016-08-30 14:01:10 -07001#!/bin/sh
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002## Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuf883b422016-08-30 14:01:10 -07003##
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Yaowu Xuf883b422016-08-30 14:01:10 -070010##
Yaowu Xu9c01aa12016-09-01 14:32:49 -070011## This file tests aomenc 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 aomenc_tests (on a new line).
Yaowu Xuf883b422016-08-30 14:01:10 -070015##
16. $(dirname $0)/tools_common.sh
17
18readonly TEST_FRAMES=10
19
20# Environment check: Make sure input is available.
21aomenc_verify_environment() {
22 if [ ! -e "${YUV_RAW_INPUT}" ]; then
23 elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
24 return 1
25 fi
26 if [ "$(aomenc_can_encode_av1)" = "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."
30 return 1
31 fi
32 fi
33 if [ -z "$(aom_tool_path aomenc)" ]; then
34 elog "aomenc not found. It must exist in LIBAOM_BIN_PATH or its parent."
35 return 1
36 fi
37}
38
39aomenc_can_encode_vp8() {
40 if [ "$(vp8_encode_available)" = "yes" ]; then
41 echo yes
42 fi
43}
44
45aomenc_can_encode_av1() {
46 if [ "$(av1_encode_available)" = "yes" ]; then
47 echo yes
48 fi
49}
50
51# Echo aomenc command line parameters allowing use of
52# hantro_collage_w352h288.yuv as input.
53yuv_input_hantro_collage() {
54 echo ""${YUV_RAW_INPUT}"
55 --width="${YUV_RAW_INPUT_WIDTH}"
56 --height="${YUV_RAW_INPUT_HEIGHT}""
57}
58
59y4m_input_non_square_par() {
60 echo ""${Y4M_NOSQ_PAR_INPUT}""
61}
62
63y4m_input_720p() {
64 echo ""${Y4M_720P_INPUT}""
65}
66
67# Echo default aomenc real time encoding params. $1 is the codec, which defaults
68# to vp8 if unspecified.
69aomenc_rt_params() {
70 local readonly codec="${1:-vp8}"
71 echo "--codec=${codec}
72 --buf-initial-sz=500
73 --buf-optimal-sz=600
74 --buf-sz=1000
75 --cpu-used=-6
76 --end-usage=cbr
77 --error-resilient=1
78 --kf-max-dist=90000
79 --lag-in-frames=0
80 --max-intra-rate=300
81 --max-q=56
82 --min-q=2
83 --noise-sensitivity=0
84 --overshoot-pct=50
85 --passes=1
86 --profile=0
87 --resize-allowed=0
88 --rt
89 --static-thresh=0
90 --undershoot-pct=50"
91}
92
93# Wrapper function for running aomenc with pipe input. Requires that
94# LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
95# input file path and shifted away. All remaining parameters are passed through
96# to aomenc.
97aomenc_pipe() {
98 local readonly encoder="$(aom_tool_path aomenc)"
99 local readonly input="$1"
100 shift
101 cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \
102 --test-decode=fatal \
103 "$@" ${devnull}
104}
105
106# Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to
107# the directory containing aomenc. $1 one is used as the input file path and
108# shifted away. All remaining parameters are passed through to aomenc.
109aomenc() {
110 local readonly encoder="$(aom_tool_path aomenc)"
111 local readonly input="$1"
112 shift
113 eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \
114 --test-decode=fatal \
115 "$@" ${devnull}
116}
117
Yaowu Xuf883b422016-08-30 14:01:10 -0700118aomenc_av1_ivf() {
119 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
120 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf"
121 aomenc $(yuv_input_hantro_collage) \
122 --codec=av1 \
123 --limit="${TEST_FRAMES}" \
124 --ivf \
125 --output="${output}"
126
127 if [ ! -e "${output}" ]; then
128 elog "Output file does not exist."
129 return 1
130 fi
131 fi
132}
133
134aomenc_av1_webm() {
135 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
136 [ "$(webm_io_available)" = "yes" ]; then
137 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
138 aomenc $(yuv_input_hantro_collage) \
139 --codec=av1 \
140 --limit="${TEST_FRAMES}" \
141 --output="${output}"
142
143 if [ ! -e "${output}" ]; then
144 elog "Output file does not exist."
145 return 1
146 fi
147 fi
148}
149
Yaowu Xuf883b422016-08-30 14:01:10 -0700150aomenc_av1_webm_2pass() {
151 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
152 [ "$(webm_io_available)" = "yes" ]; then
153 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
154 aomenc $(yuv_input_hantro_collage) \
155 --codec=av1 \
156 --limit="${TEST_FRAMES}" \
157 --output="${output}" \
158 --passes=2
159
160 if [ ! -e "${output}" ]; then
161 elog "Output file does not exist."
162 return 1
163 fi
164 fi
165}
166
167aomenc_av1_ivf_lossless() {
168 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
169 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
170 aomenc $(yuv_input_hantro_collage) \
171 --codec=av1 \
172 --limit="${TEST_FRAMES}" \
173 --ivf \
174 --output="${output}" \
175 --lossless=1
176
177 if [ ! -e "${output}" ]; then
178 elog "Output file does not exist."
179 return 1
180 fi
181 fi
182}
183
184aomenc_av1_ivf_minq0_maxq0() {
185 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
186 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
187 aomenc $(yuv_input_hantro_collage) \
188 --codec=av1 \
189 --limit="${TEST_FRAMES}" \
190 --ivf \
191 --output="${output}" \
192 --min-q=0 \
193 --max-q=0
194
195 if [ ! -e "${output}" ]; then
196 elog "Output file does not exist."
197 return 1
198 fi
199 fi
200}
201
202aomenc_av1_webm_lag10_frames20() {
203 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
204 [ "$(webm_io_available)" = "yes" ]; then
205 local readonly lag_total_frames=20
206 local readonly lag_frames=10
207 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag10_frames20.webm"
208 aomenc $(yuv_input_hantro_collage) \
209 --codec=av1 \
210 --limit="${lag_total_frames}" \
211 --lag-in-frames="${lag_frames}" \
212 --output="${output}" \
213 --passes=2 \
214 --auto-alt-ref=1
215
216 if [ ! -e "${output}" ]; then
217 elog "Output file does not exist."
218 return 1
219 fi
220 fi
221}
222
223# TODO(fgalligan): Test that DisplayWidth is different than video width.
224aomenc_av1_webm_non_square_par() {
225 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
226 [ "$(webm_io_available)" = "yes" ]; then
227 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
228 aomenc $(y4m_input_non_square_par) \
229 --codec=av1 \
230 --limit="${TEST_FRAMES}" \
231 --output="${output}"
232
233 if [ ! -e "${output}" ]; then
234 elog "Output file does not exist."
235 return 1
236 fi
237 fi
238}
239
Jim Bankoski23938a72016-05-18 08:08:47 -0700240aomenc_tests="aomenc_av1_ivf
Yaowu Xuf883b422016-08-30 14:01:10 -0700241 aomenc_av1_webm
Yaowu Xuf883b422016-08-30 14:01:10 -0700242 aomenc_av1_webm_2pass
243 aomenc_av1_ivf_lossless
244 aomenc_av1_ivf_minq0_maxq0
245 aomenc_av1_webm_lag10_frames20
246 aomenc_av1_webm_non_square_par"
247
248run_tests aomenc_verify_environment "${aomenc_tests}"