blob: fcba898c8174dda6fca3c13e65d1091ef2e448f8 [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 Xuf883b422016-08-30 14:01:10 -070018# Environment check: Make sure input is available.
19aomenc_verify_environment() {
20 if [ ! -e "${YUV_RAW_INPUT}" ]; then
Yaowu Xu97aa09f2016-10-12 08:25:39 -070021 elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
Yaowu Xuf883b422016-08-30 14:01:10 -070022 return 1
23 fi
24 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
25 if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
26 elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
Yaowu Xu97aa09f2016-10-12 08:25:39 -070027 elog "LIBAOM_TEST_DATA_PATH."
Yaowu Xuf883b422016-08-30 14:01:10 -070028 return 1
29 fi
30 fi
31 if [ -z "$(aom_tool_path aomenc)" ]; then
32 elog "aomenc not found. It must exist in LIBAOM_BIN_PATH or its parent."
33 return 1
34 fi
35}
36
Yaowu Xu8d510e22016-10-14 11:05:54 -070037aomenc_can_encode_av1() {
38 if [ "$(av1_encode_available)" = "yes" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -070039 echo yes
40 fi
41}
42
43aomenc_can_encode_av1() {
44 if [ "$(av1_encode_available)" = "yes" ]; then
45 echo yes
46 fi
47}
48
Jim Bankoskie78a9642016-05-25 07:02:19 -070049# Utilities that echo aomenc input file parameters.
Yaowu Xuf883b422016-08-30 14:01:10 -070050y4m_input_non_square_par() {
51 echo ""${Y4M_NOSQ_PAR_INPUT}""
52}
53
54y4m_input_720p() {
55 echo ""${Y4M_720P_INPUT}""
56}
57
Yaowu Xuf883b422016-08-30 14:01:10 -070058# Wrapper function for running aomenc with pipe input. Requires that
59# LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
60# input file path and shifted away. All remaining parameters are passed through
61# to aomenc.
62aomenc_pipe() {
63 local readonly encoder="$(aom_tool_path aomenc)"
64 local readonly input="$1"
65 shift
66 cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \
67 --test-decode=fatal \
68 "$@" ${devnull}
69}
70
71# Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to
72# the directory containing aomenc. $1 one is used as the input file path and
73# shifted away. All remaining parameters are passed through to aomenc.
74aomenc() {
75 local readonly encoder="$(aom_tool_path aomenc)"
76 local readonly input="$1"
77 shift
78 eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \
79 --test-decode=fatal \
80 "$@" ${devnull}
81}
82
Yaowu Xuf883b422016-08-30 14:01:10 -070083aomenc_av1_ivf() {
84 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
85 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -070086 aomenc $(yuv_raw_input) \
Tom Finegan9a74bb62018-02-15 14:59:40 -080087 $(aomenc_encode_test_fast_params) \
88 --passes=1 \
Yaowu Xuf883b422016-08-30 14:01:10 -070089 --ivf \
90 --output="${output}"
91
92 if [ ! -e "${output}" ]; then
93 elog "Output file does not exist."
94 return 1
95 fi
96 fi
97}
98
99aomenc_av1_webm() {
100 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
101 [ "$(webm_io_available)" = "yes" ]; then
102 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700103 aomenc $(yuv_raw_input) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700104 --codec=av1 \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800105 $(aomenc_encode_test_fast_params) \
106 --passes=1 \
Yaowu Xuf883b422016-08-30 14:01:10 -0700107 --output="${output}"
108
109 if [ ! -e "${output}" ]; then
110 elog "Output file does not exist."
111 return 1
112 fi
113 fi
114}
115
Yaowu Xuf883b422016-08-30 14:01:10 -0700116aomenc_av1_webm_2pass() {
117 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
118 [ "$(webm_io_available)" = "yes" ]; then
119 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700120 aomenc $(yuv_raw_input) \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800121 $(aomenc_encode_test_fast_params) \
122 --passes=2 \
123 --output="${output}"
Yaowu Xuf883b422016-08-30 14:01:10 -0700124
125 if [ ! -e "${output}" ]; then
126 elog "Output file does not exist."
127 return 1
128 fi
129 fi
130}
131
132aomenc_av1_ivf_lossless() {
133 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
134 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700135 aomenc $(yuv_raw_input) \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800136 $(aomenc_encode_test_fast_params) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700137 --ivf \
138 --output="${output}" \
139 --lossless=1
140
141 if [ ! -e "${output}" ]; then
142 elog "Output file does not exist."
143 return 1
144 fi
145 fi
146}
147
148aomenc_av1_ivf_minq0_maxq0() {
149 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
150 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700151 aomenc $(yuv_raw_input) \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800152 $(aomenc_encode_test_fast_params) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700153 --ivf \
154 --output="${output}" \
155 --min-q=0 \
156 --max-q=0
157
158 if [ ! -e "${output}" ]; then
159 elog "Output file does not exist."
160 return 1
161 fi
162 fi
163}
164
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800165aomenc_av1_webm_lag5_frames10() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700166 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
167 [ "$(webm_io_available)" = "yes" ]; then
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800168 local readonly lag_total_frames=10
169 local readonly lag_frames=5
170 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag5_frames10.webm"
Jim Bankoskie78a9642016-05-25 07:02:19 -0700171 aomenc $(yuv_raw_input) \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800172 $(aomenc_encode_test_fast_params) \
173 --limit=${lag_total_frames} \
174 --lag-in-frames=${lag_frames} \
Yaowu Xuf883b422016-08-30 14:01:10 -0700175 --output="${output}" \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800176 --passes=2
Yaowu Xuf883b422016-08-30 14:01:10 -0700177
178 if [ ! -e "${output}" ]; then
179 elog "Output file does not exist."
180 return 1
181 fi
182 fi
183}
184
185# TODO(fgalligan): Test that DisplayWidth is different than video width.
186aomenc_av1_webm_non_square_par() {
187 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
188 [ "$(webm_io_available)" = "yes" ]; then
189 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
190 aomenc $(y4m_input_non_square_par) \
Tom Finegan9a74bb62018-02-15 14:59:40 -0800191 $(aomenc_encode_test_fast_params) \
Yaowu Xuf883b422016-08-30 14:01:10 -0700192 --output="${output}"
193
194 if [ ! -e "${output}" ]; then
195 elog "Output file does not exist."
196 return 1
197 fi
198 fi
199}
200
Hui Sub1b76b32018-02-27 15:24:48 -0800201aomenc_av1_webm_cdf_update_mode() {
202 if [ "$(aom_config_option_enabled CONFIG_CDF_UPDATE_MODE)" = "yes" ] && \
203 [ "$(aomenc_can_encode_av1)" = "yes" ] && \
204 [ "$(webm_io_available)" = "yes" ]; then
205 for mode in 0 1 2; do
206 local readonly output="${AOM_TEST_OUTPUT_DIR}/cdf_mode_${mode}.webm"
207 aomenc $(yuv_raw_input) \
208 --codec=av1 \
209 $(aomenc_encode_test_fast_params) \
210 --passes=2 \
211 --cpu-used=2 \
212 --cdf-update-mode=${mode} \
213 --output="${output}"
214
215 if [ ! -e "${output}" ]; then
216 elog "Output file does not exist."
217 return 1
218 fi
219 done
220 fi
221}
222
Jim Bankoski23938a72016-05-18 08:08:47 -0700223aomenc_tests="aomenc_av1_ivf
Yaowu Xuf883b422016-08-30 14:01:10 -0700224 aomenc_av1_webm
Yaowu Xuf883b422016-08-30 14:01:10 -0700225 aomenc_av1_webm_2pass
226 aomenc_av1_ivf_lossless
227 aomenc_av1_ivf_minq0_maxq0
Yaowu Xuf8cb5a62016-12-19 13:44:41 -0800228 aomenc_av1_webm_lag5_frames10
Hui Sub1b76b32018-02-27 15:24:48 -0800229 aomenc_av1_webm_non_square_par
230 aomenc_av1_webm_cdf_update_mode"
Yaowu Xuf883b422016-08-30 14:01:10 -0700231
232run_tests aomenc_verify_environment "${aomenc_tests}"