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 | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 18 | readonly TEST_FRAMES=5 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | |
| 20 | # Environment check: Make sure input is available. |
| 21 | aomenc_verify_environment() { |
| 22 | if [ ! -e "${YUV_RAW_INPUT}" ]; then |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 23 | 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] | 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" |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 29 | elog "LIBAOM_TEST_DATA_PATH." |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 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 | |
Yaowu Xu | 8d510e2 | 2016-10-14 11:05:54 -0700 | [diff] [blame] | 39 | aomenc_can_encode_av1() { |
| 40 | if [ "$(av1_encode_available)" = "yes" ]; then |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 41 | echo yes |
| 42 | fi |
| 43 | } |
| 44 | |
| 45 | aomenc_can_encode_av1() { |
| 46 | if [ "$(av1_encode_available)" = "yes" ]; then |
| 47 | echo yes |
| 48 | fi |
| 49 | } |
| 50 | |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 51 | # Utilities that echo aomenc input file parameters. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 52 | y4m_input_non_square_par() { |
| 53 | echo ""${Y4M_NOSQ_PAR_INPUT}"" |
| 54 | } |
| 55 | |
| 56 | y4m_input_720p() { |
| 57 | echo ""${Y4M_720P_INPUT}"" |
| 58 | } |
| 59 | |
| 60 | # Echo default aomenc real time encoding params. $1 is the codec, which defaults |
Yaowu Xu | 8d510e2 | 2016-10-14 11:05:54 -0700 | [diff] [blame] | 61 | # to av1 if unspecified. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 62 | aomenc_rt_params() { |
Yaowu Xu | 8d510e2 | 2016-10-14 11:05:54 -0700 | [diff] [blame] | 63 | local readonly codec="${1:-av1}" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | 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. |
| 90 | aomenc_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. |
| 102 | aomenc() { |
| 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 111 | aomenc_av1_ivf() { |
| 112 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 113 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf" |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 114 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 115 | --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 | |
| 127 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 131 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 132 | --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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 143 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 147 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 148 | --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 | |
| 160 | aomenc_av1_ivf_lossless() { |
| 161 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 162 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf" |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 163 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 164 | --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 | |
| 177 | aomenc_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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 180 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 181 | --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 Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 195 | aomenc_av1_webm_lag5_frames10() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 196 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 197 | [ "$(webm_io_available)" = "yes" ]; then |
Yaowu Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 198 | 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 Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 201 | aomenc $(yuv_raw_input) \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 202 | --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. |
| 217 | aomenc_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 Bankoski | 23938a7 | 2016-05-18 08:08:47 -0700 | [diff] [blame] | 233 | aomenc_tests="aomenc_av1_ivf |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 234 | aomenc_av1_webm |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 235 | aomenc_av1_webm_2pass |
| 236 | aomenc_av1_ivf_lossless |
| 237 | aomenc_av1_ivf_minq0_maxq0 |
Yaowu Xu | f8cb5a6 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 238 | aomenc_av1_webm_lag5_frames10 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 239 | aomenc_av1_webm_non_square_par" |
| 240 | |
| 241 | run_tests aomenc_verify_environment "${aomenc_tests}" |