blob: 57a4c28a5a331dae7909e3f28d2cad08c15867dd [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
Yaowu Xuf8cb5a62016-12-19 13:44:41 -080018readonly TEST_FRAMES=5
Yaowu Xuf883b422016-08-30 14:01:10 -070019
20# Environment check: Make sure input is available.
21aomenc_verify_environment() {
22 if [ ! -e "${YUV_RAW_INPUT}" ]; then
Yaowu Xu97aa09f2016-10-12 08:25:39 -070023 elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
Yaowu Xuf883b422016-08-30 14:01:10 -070024 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"
Yaowu Xu97aa09f2016-10-12 08:25:39 -070029 elog "LIBAOM_TEST_DATA_PATH."
Yaowu Xuf883b422016-08-30 14:01:10 -070030 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
Yaowu Xu8d510e22016-10-14 11:05:54 -070039aomenc_can_encode_av1() {
40 if [ "$(av1_encode_available)" = "yes" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -070041 echo yes
42 fi
43}
44
45aomenc_can_encode_av1() {
46 if [ "$(av1_encode_available)" = "yes" ]; then
47 echo yes
48 fi
49}
50
Jim Bankoskie78a9642016-05-25 07:02:19 -070051# Utilities that echo aomenc input file parameters.
Yaowu Xuf883b422016-08-30 14:01:10 -070052y4m_input_non_square_par() {
53 echo ""${Y4M_NOSQ_PAR_INPUT}""
54}
55
56y4m_input_720p() {
57 echo ""${Y4M_720P_INPUT}""
58}
59
60# Echo default aomenc real time encoding params. $1 is the codec, which defaults
Yaowu Xu8d510e22016-10-14 11:05:54 -070061# to av1 if unspecified.
Yaowu Xuf883b422016-08-30 14:01:10 -070062aomenc_rt_params() {
Yaowu Xu8d510e22016-10-14 11:05:54 -070063 local readonly codec="${1:-av1}"
Yaowu Xuf883b422016-08-30 14:01:10 -070064 echo "--codec=${codec}
65 --buf-initial-sz=500
66 --buf-optimal-sz=600
67 --buf-sz=1000
68 --cpu-used=-6
69 --end-usage=cbr
70 --error-resilient=1
71 --kf-max-dist=90000
72 --lag-in-frames=0
73 --max-intra-rate=300
74 --max-q=56
75 --min-q=2
76 --noise-sensitivity=0
77 --overshoot-pct=50
78 --passes=1
79 --profile=0
80 --resize-allowed=0
81 --rt
82 --static-thresh=0
83 --undershoot-pct=50"
84}
85
86# Wrapper function for running aomenc with pipe input. Requires that
87# LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
88# input file path and shifted away. All remaining parameters are passed through
89# to aomenc.
90aomenc_pipe() {
91 local readonly encoder="$(aom_tool_path aomenc)"
92 local readonly input="$1"
93 shift
94 cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \
95 --test-decode=fatal \
96 "$@" ${devnull}
97}
98
99# Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to
100# the directory containing aomenc. $1 one is used as the input file path and
101# shifted away. All remaining parameters are passed through to aomenc.
102aomenc() {
103 local readonly encoder="$(aom_tool_path aomenc)"
104 local readonly input="$1"
105 shift
106 eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \
107 --test-decode=fatal \
108 "$@" ${devnull}
109}
110
Yaowu Xuf883b422016-08-30 14:01:10 -0700111aomenc_av1_ivf() {
112 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
113 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700114 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700115 --codec=av1 \
116 --limit="${TEST_FRAMES}" \
117 --ivf \
118 --output="${output}"
119
120 if [ ! -e "${output}" ]; then
121 elog "Output file does not exist."
122 return 1
123 fi
124 fi
125}
126
127aomenc_av1_webm() {
128 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
129 [ "$(webm_io_available)" = "yes" ]; then
130 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700131 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700132 --codec=av1 \
133 --limit="${TEST_FRAMES}" \
134 --output="${output}"
135
136 if [ ! -e "${output}" ]; then
137 elog "Output file does not exist."
138 return 1
139 fi
140 fi
141}
142
Yaowu Xuf883b422016-08-30 14:01:10 -0700143aomenc_av1_webm_2pass() {
144 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
145 [ "$(webm_io_available)" = "yes" ]; then
146 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700147 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700148 --codec=av1 \
149 --limit="${TEST_FRAMES}" \
150 --output="${output}" \
151 --passes=2
152
153 if [ ! -e "${output}" ]; then
154 elog "Output file does not exist."
155 return 1
156 fi
157 fi
158}
159
160aomenc_av1_ivf_lossless() {
161 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
162 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700163 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700164 --codec=av1 \
165 --limit="${TEST_FRAMES}" \
166 --ivf \
167 --output="${output}" \
168 --lossless=1
169
170 if [ ! -e "${output}" ]; then
171 elog "Output file does not exist."
172 return 1
173 fi
174 fi
175}
176
177aomenc_av1_ivf_minq0_maxq0() {
178 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
179 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700180 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700181 --codec=av1 \
182 --limit="${TEST_FRAMES}" \
183 --ivf \
184 --output="${output}" \
185 --min-q=0 \
186 --max-q=0
187
188 if [ ! -e "${output}" ]; then
189 elog "Output file does not exist."
190 return 1
191 fi
192 fi
193}
194
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800195aomenc_av1_webm_lag5_frames10() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700196 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
197 [ "$(webm_io_available)" = "yes" ]; then
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800198 local readonly lag_total_frames=10
199 local readonly lag_frames=5
200 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag5_frames10.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700201 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700202 --codec=av1 \
203 --limit="${lag_total_frames}" \
204 --lag-in-frames="${lag_frames}" \
205 --output="${output}" \
206 --passes=2 \
207 --auto-alt-ref=1
208
209 if [ ! -e "${output}" ]; then
210 elog "Output file does not exist."
211 return 1
212 fi
213 fi
214}
215
216# TODO(fgalligan): Test that DisplayWidth is different than video width.
217aomenc_av1_webm_non_square_par() {
218 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
219 [ "$(webm_io_available)" = "yes" ]; then
220 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
221 aomenc $(y4m_input_non_square_par) \
222 --codec=av1 \
223 --limit="${TEST_FRAMES}" \
224 --output="${output}"
225
226 if [ ! -e "${output}" ]; then
227 elog "Output file does not exist."
228 return 1
229 fi
230 fi
231}
232
Jim Bankoski23938a72016-05-18 08:08:47 -0700233aomenc_tests="aomenc_av1_ivf
Yaowu Xuf883b422016-08-30 14:01:10 -0700234 aomenc_av1_webm
Yaowu Xuf883b422016-08-30 14:01:10 -0700235 aomenc_av1_webm_2pass
236 aomenc_av1_ivf_lossless
237 aomenc_av1_ivf_minq0_maxq0
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800238 aomenc_av1_webm_lag5_frames10
Yaowu Xuf883b422016-08-30 14:01:10 -0700239 aomenc_av1_webm_non_square_par"
240
241run_tests aomenc_verify_environment "${aomenc_tests}"