Add dr prediction test
[aom.git] / test / aomenc.sh
bloba0ab8c8aa2b9896cb1b9234584d6c0e2afbb64d5
1 #!/bin/sh
2 ## Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 ##
4 ## 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.
11 ## 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).
16 . $(dirname $0)/tools_common.sh
18 # Environment check: Make sure input is available.
19 aomenc_verify_environment() {
20 if [ ! -e "${YUV_RAW_INPUT}" ]; then
21 elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
22 return 1
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"
27 elog "LIBAOM_TEST_DATA_PATH."
28 return 1
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
37 aomenc_can_encode_av1() {
38 if [ "$(av1_encode_available)" = "yes" ]; then
39 echo yes
43 aomenc_can_encode_av1() {
44 if [ "$(av1_encode_available)" = "yes" ]; then
45 echo yes
49 # Utilities that echo aomenc input file parameters.
50 y4m_input_non_square_par() {
51 echo ""${Y4M_NOSQ_PAR_INPUT}""
54 y4m_input_720p() {
55 echo ""${Y4M_720P_INPUT}""
58 # 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.
62 aomenc_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}
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.
74 aomenc() {
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}
83 aomenc_av1_ivf() {
84 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
85 local output="${AV1_IVF_FILE}"
86 if [ -e "${AV1_IVF_FILE}" ]; then
87 output="${AOM_TEST_OUTPUT_DIR}/av1_test.ivf"
89 aomenc $(yuv_raw_input) \
90 $(aomenc_encode_test_fast_params) \
91 --ivf \
92 --output="${output}"
94 if [ ! -e "${output}" ]; then
95 elog "Output file does not exist."
96 return 1
101 aomenc_av1_obu_annexb() {
102 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
103 local output="${AV1_OBU_ANNEXB_FILE}"
104 if [ -e "${AV1_OBU_ANNEXB_FILE}" ]; then
105 output="${AOM_TEST_OUTPUT_DIR}/av1_test.annexb.obu"
107 aomenc $(yuv_raw_input) \
108 $(aomenc_encode_test_fast_params) \
109 --obu \
110 --annexb=1 \
111 --output="${output}"
113 if [ ! -e "${output}" ]; then
114 elog "Output file does not exist."
115 return 1
120 aomenc_av1_obu_section5() {
121 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
122 local output="${AV1_OBU_SEC5_FILE}"
123 if [ -e "${AV1_OBU_SEC5_FILE}" ]; then
124 output="${AOM_TEST_OUTPUT_DIR}/av1_test.section5.obu"
126 aomenc $(yuv_raw_input) \
127 $(aomenc_encode_test_fast_params) \
128 --obu \
129 --output="${output}"
131 if [ ! -e "${output}" ]; then
132 elog "Output file does not exist."
133 return 1
138 aomenc_av1_webm() {
139 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
140 [ "$(webm_io_available)" = "yes" ]; then
141 local output="${AV1_WEBM_FILE}"
142 if [ -e "${AV1_WEBM_FILE}" ]; then
143 output="${AOM_TEST_OUTPUT_DIR}/av1_test.webm"
145 aomenc $(yuv_raw_input) \
146 $(aomenc_encode_test_fast_params) \
147 --output="${output}"
149 if [ ! -e "${output}" ]; then
150 elog "Output file does not exist."
151 return 1
156 aomenc_av1_webm_1pass() {
157 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
158 [ "$(webm_io_available)" = "yes" ]; then
159 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_test.webm"
160 aomenc $(yuv_raw_input) \
161 $(aomenc_encode_test_fast_params) \
162 --passes=1 \
163 --output="${output}"
165 if [ ! -e "${output}" ]; then
166 elog "Output file does not exist."
167 return 1
172 aomenc_av1_ivf_lossless() {
173 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
174 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
175 aomenc $(yuv_raw_input) \
176 $(aomenc_encode_test_fast_params) \
177 --ivf \
178 --output="${output}" \
179 --lossless=1
181 if [ ! -e "${output}" ]; then
182 elog "Output file does not exist."
183 return 1
188 aomenc_av1_ivf_minq0_maxq0() {
189 if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
190 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
191 aomenc $(yuv_raw_input) \
192 $(aomenc_encode_test_fast_params) \
193 --ivf \
194 --output="${output}" \
195 --min-q=0 \
196 --max-q=0
198 if [ ! -e "${output}" ]; then
199 elog "Output file does not exist."
200 return 1
205 aomenc_av1_webm_lag5_frames10() {
206 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
207 [ "$(webm_io_available)" = "yes" ]; then
208 local readonly lag_total_frames=10
209 local readonly lag_frames=5
210 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag5_frames10.webm"
211 aomenc $(yuv_raw_input) \
212 $(aomenc_encode_test_fast_params) \
213 --limit=${lag_total_frames} \
214 --lag-in-frames=${lag_frames} \
215 --output="${output}"
217 if [ ! -e "${output}" ]; then
218 elog "Output file does not exist."
219 return 1
224 # TODO(fgalligan): Test that DisplayWidth is different than video width.
225 aomenc_av1_webm_non_square_par() {
226 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
227 [ "$(webm_io_available)" = "yes" ]; then
228 local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
229 aomenc $(y4m_input_non_square_par) \
230 $(aomenc_encode_test_fast_params) \
231 --output="${output}"
233 if [ ! -e "${output}" ]; then
234 elog "Output file does not exist."
235 return 1
240 aomenc_av1_webm_cdf_update_mode() {
241 if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
242 [ "$(webm_io_available)" = "yes" ]; then
243 for mode in 0 1 2; do
244 local readonly output="${AOM_TEST_OUTPUT_DIR}/cdf_mode_${mode}.webm"
245 aomenc $(yuv_raw_input) \
246 $(aomenc_encode_test_fast_params) \
247 --cdf-update-mode=${mode} \
248 --output="${output}"
250 if [ ! -e "${output}" ]; then
251 elog "Output file does not exist."
252 return 1
254 done
258 aomenc_tests="aomenc_av1_ivf
259 aomenc_av1_obu_annexb
260 aomenc_av1_obu_section5
261 aomenc_av1_webm
262 aomenc_av1_webm_1pass
263 aomenc_av1_ivf_lossless
264 aomenc_av1_ivf_minq0_maxq0
265 aomenc_av1_webm_lag5_frames10
266 aomenc_av1_webm_non_square_par
267 aomenc_av1_webm_cdf_update_mode"
269 run_tests aomenc_verify_environment "${aomenc_tests}"