Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | ## Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3 | ## |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 10 | ## |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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). |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | ## |
| 16 | . $(dirname $0)/tools_common.sh |
| 17 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 18 | # Environment check: Make sure input is available. |
| 19 | aomenc_verify_environment() { |
| 20 | if [ ! -e "${YUV_RAW_INPUT}" ]; then |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 21 | elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH." |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 22 | 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 Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 27 | elog "LIBAOM_TEST_DATA_PATH." |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 28 | 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 Xu | 8d510e2 | 2016-10-14 11:05:54 -0700 | [diff] [blame] | 37 | aomenc_can_encode_av1() { |
| 38 | if [ "$(av1_encode_available)" = "yes" ]; then |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 39 | echo yes |
| 40 | fi |
| 41 | } |
| 42 | |
| 43 | aomenc_can_encode_av1() { |
| 44 | if [ "$(av1_encode_available)" = "yes" ]; then |
| 45 | echo yes |
| 46 | fi |
| 47 | } |
| 48 | |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 49 | # Utilities that echo aomenc input file parameters. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 50 | y4m_input_non_square_par() { |
| 51 | echo ""${Y4M_NOSQ_PAR_INPUT}"" |
| 52 | } |
| 53 | |
| 54 | y4m_input_720p() { |
| 55 | echo ""${Y4M_720P_INPUT}"" |
| 56 | } |
| 57 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 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} |
| 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. |
| 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} |
| 81 | } |
| 82 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 83 | aomenc_av1_ivf() { |
| 84 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 85 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf" |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 86 | aomenc $(yuv_raw_input) \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 87 | $(aomenc_encode_test_fast_params) \ |
| 88 | --passes=1 \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 89 | --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 | |
| 99 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 103 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 104 | --codec=av1 \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 105 | $(aomenc_encode_test_fast_params) \ |
| 106 | --passes=1 \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 107 | --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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 116 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 120 | aomenc $(yuv_raw_input) \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 121 | $(aomenc_encode_test_fast_params) \ |
| 122 | --passes=2 \ |
| 123 | --output="${output}" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 124 | |
| 125 | if [ ! -e "${output}" ]; then |
| 126 | elog "Output file does not exist." |
| 127 | return 1 |
| 128 | fi |
| 129 | fi |
| 130 | } |
| 131 | |
| 132 | aomenc_av1_ivf_lossless() { |
| 133 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 134 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf" |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 135 | aomenc $(yuv_raw_input) \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 136 | $(aomenc_encode_test_fast_params) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 137 | --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 | |
| 148 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 151 | aomenc $(yuv_raw_input) \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 152 | $(aomenc_encode_test_fast_params) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 153 | --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 Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 165 | aomenc_av1_webm_lag5_frames10() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 166 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 167 | [ "$(webm_io_available)" = "yes" ]; then |
Yaowu Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 168 | 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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 171 | aomenc $(yuv_raw_input) \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 172 | $(aomenc_encode_test_fast_params) \ |
| 173 | --limit=${lag_total_frames} \ |
| 174 | --lag-in-frames=${lag_frames} \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 175 | --output="${output}" \ |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 176 | --passes=2 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 177 | |
| 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. |
| 186 | aomenc_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 Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 191 | $(aomenc_encode_test_fast_params) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 192 | --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 Su | b1b76b3 | 2018-02-27 15:24:48 -0800 | [diff] [blame] | 201 | aomenc_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 Bankoski | 23938a7 | 2016-05-18 08:08:47 -0700 | [diff] [blame] | 223 | aomenc_tests="aomenc_av1_ivf |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 224 | aomenc_av1_webm |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 225 | aomenc_av1_webm_2pass |
| 226 | aomenc_av1_ivf_lossless |
| 227 | aomenc_av1_ivf_minq0_maxq0 |
Yaowu Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 228 | aomenc_av1_webm_lag5_frames10 |
Hui Su | b1b76b3 | 2018-02-27 15:24:48 -0800 | [diff] [blame] | 229 | aomenc_av1_webm_non_square_par |
| 230 | aomenc_av1_webm_cdf_update_mode" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 231 | |
| 232 | run_tests aomenc_verify_environment "${aomenc_tests}" |