Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | ## |
| 3 | ## Copyright (c) 2014 The WebM project authors. All Rights Reserved. |
| 4 | ## |
| 5 | ## Use of this source code is governed by a BSD-style license |
| 6 | ## that can be found in the LICENSE file in the root of the source |
| 7 | ## tree. An additional intellectual property rights grant can be found |
| 8 | ## in the file PATENTS. All contributing project authors may |
| 9 | ## be found in the AUTHORS file in the root of the source tree. |
| 10 | ## |
| 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). |
| 15 | ## |
| 16 | . $(dirname $0)/tools_common.sh |
| 17 | |
| 18 | readonly TEST_FRAMES=10 |
| 19 | |
| 20 | # Environment check: Make sure input is available. |
| 21 | aomenc_verify_environment() { |
| 22 | if [ ! -e "${YUV_RAW_INPUT}" ]; then |
| 23 | elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH." |
| 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" |
| 29 | elog "LIBVPX_TEST_DATA_PATH." |
| 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 | |
| 39 | aomenc_can_encode_vp8() { |
| 40 | if [ "$(vp8_encode_available)" = "yes" ]; then |
| 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 | |
| 51 | # Echo aomenc command line parameters allowing use of |
| 52 | # hantro_collage_w352h288.yuv as input. |
| 53 | yuv_input_hantro_collage() { |
| 54 | echo ""${YUV_RAW_INPUT}" |
| 55 | --width="${YUV_RAW_INPUT_WIDTH}" |
| 56 | --height="${YUV_RAW_INPUT_HEIGHT}"" |
| 57 | } |
| 58 | |
| 59 | y4m_input_non_square_par() { |
| 60 | echo ""${Y4M_NOSQ_PAR_INPUT}"" |
| 61 | } |
| 62 | |
| 63 | y4m_input_720p() { |
| 64 | echo ""${Y4M_720P_INPUT}"" |
| 65 | } |
| 66 | |
| 67 | # Echo default aomenc real time encoding params. $1 is the codec, which defaults |
| 68 | # to vp8 if unspecified. |
| 69 | aomenc_rt_params() { |
| 70 | local readonly codec="${1:-vp8}" |
| 71 | echo "--codec=${codec} |
| 72 | --buf-initial-sz=500 |
| 73 | --buf-optimal-sz=600 |
| 74 | --buf-sz=1000 |
| 75 | --cpu-used=-6 |
| 76 | --end-usage=cbr |
| 77 | --error-resilient=1 |
| 78 | --kf-max-dist=90000 |
| 79 | --lag-in-frames=0 |
| 80 | --max-intra-rate=300 |
| 81 | --max-q=56 |
| 82 | --min-q=2 |
| 83 | --noise-sensitivity=0 |
| 84 | --overshoot-pct=50 |
| 85 | --passes=1 |
| 86 | --profile=0 |
| 87 | --resize-allowed=0 |
| 88 | --rt |
| 89 | --static-thresh=0 |
| 90 | --undershoot-pct=50" |
| 91 | } |
| 92 | |
| 93 | # Wrapper function for running aomenc with pipe input. Requires that |
| 94 | # LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the |
| 95 | # input file path and shifted away. All remaining parameters are passed through |
| 96 | # to aomenc. |
| 97 | aomenc_pipe() { |
| 98 | local readonly encoder="$(aom_tool_path aomenc)" |
| 99 | local readonly input="$1" |
| 100 | shift |
| 101 | cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \ |
| 102 | --test-decode=fatal \ |
| 103 | "$@" ${devnull} |
| 104 | } |
| 105 | |
| 106 | # Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to |
| 107 | # the directory containing aomenc. $1 one is used as the input file path and |
| 108 | # shifted away. All remaining parameters are passed through to aomenc. |
| 109 | aomenc() { |
| 110 | local readonly encoder="$(aom_tool_path aomenc)" |
| 111 | local readonly input="$1" |
| 112 | shift |
| 113 | eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \ |
| 114 | --test-decode=fatal \ |
| 115 | "$@" ${devnull} |
| 116 | } |
| 117 | |
| 118 | aomenc_vp8_ivf() { |
| 119 | if [ "$(aomenc_can_encode_vp8)" = "yes" ]; then |
| 120 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8.ivf" |
| 121 | aomenc $(yuv_input_hantro_collage) \ |
| 122 | --codec=vp8 \ |
| 123 | --limit="${TEST_FRAMES}" \ |
| 124 | --ivf \ |
| 125 | --output="${output}" |
| 126 | |
| 127 | if [ ! -e "${output}" ]; then |
| 128 | elog "Output file does not exist." |
| 129 | return 1 |
| 130 | fi |
| 131 | fi |
| 132 | } |
| 133 | |
| 134 | aomenc_vp8_webm() { |
| 135 | if [ "$(aomenc_can_encode_vp8)" = "yes" ] && \ |
| 136 | [ "$(webm_io_available)" = "yes" ]; then |
| 137 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8.webm" |
| 138 | aomenc $(yuv_input_hantro_collage) \ |
| 139 | --codec=vp8 \ |
| 140 | --limit="${TEST_FRAMES}" \ |
| 141 | --output="${output}" |
| 142 | |
| 143 | if [ ! -e "${output}" ]; then |
| 144 | elog "Output file does not exist." |
| 145 | return 1 |
| 146 | fi |
| 147 | fi |
| 148 | } |
| 149 | |
| 150 | aomenc_vp8_webm_rt() { |
| 151 | if [ "$(aomenc_can_encode_vp8)" = "yes" ] && \ |
| 152 | [ "$(webm_io_available)" = "yes" ]; then |
| 153 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8_rt.webm" |
| 154 | aomenc $(yuv_input_hantro_collage) \ |
| 155 | $(aomenc_rt_params vp8) \ |
| 156 | --output="${output}" |
| 157 | if [ ! -e "${output}" ]; then |
| 158 | elog "Output file does not exist." |
| 159 | return 1 |
| 160 | fi |
| 161 | fi |
| 162 | } |
| 163 | |
| 164 | aomenc_vp8_webm_2pass() { |
| 165 | if [ "$(aomenc_can_encode_vp8)" = "yes" ] && \ |
| 166 | [ "$(webm_io_available)" = "yes" ]; then |
| 167 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8.webm" |
| 168 | aomenc $(yuv_input_hantro_collage) \ |
| 169 | --codec=vp8 \ |
| 170 | --limit="${TEST_FRAMES}" \ |
| 171 | --output="${output}" \ |
| 172 | --passes=2 |
| 173 | |
| 174 | if [ ! -e "${output}" ]; then |
| 175 | elog "Output file does not exist." |
| 176 | return 1 |
| 177 | fi |
| 178 | fi |
| 179 | } |
| 180 | |
| 181 | aomenc_vp8_webm_lag10_frames20() { |
| 182 | if [ "$(aomenc_can_encode_vp8)" = "yes" ] && \ |
| 183 | [ "$(webm_io_available)" = "yes" ]; then |
| 184 | local readonly lag_total_frames=20 |
| 185 | local readonly lag_frames=10 |
| 186 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8_lag10_frames20.webm" |
| 187 | aomenc $(yuv_input_hantro_collage) \ |
| 188 | --codec=vp8 \ |
| 189 | --limit="${lag_total_frames}" \ |
| 190 | --lag-in-frames="${lag_frames}" \ |
| 191 | --output="${output}" \ |
| 192 | --auto-alt-ref=1 \ |
| 193 | --passes=2 |
| 194 | |
| 195 | if [ ! -e "${output}" ]; then |
| 196 | elog "Output file does not exist." |
| 197 | return 1 |
| 198 | fi |
| 199 | fi |
| 200 | } |
| 201 | |
| 202 | aomenc_vp8_ivf_piped_input() { |
| 203 | if [ "$(aomenc_can_encode_vp8)" = "yes" ]; then |
| 204 | local readonly output="${AOM_TEST_OUTPUT_DIR}/vp8_piped_input.ivf" |
| 205 | aomenc_pipe $(yuv_input_hantro_collage) \ |
| 206 | --codec=vp8 \ |
| 207 | --limit="${TEST_FRAMES}" \ |
| 208 | --ivf \ |
| 209 | --output="${output}" |
| 210 | |
| 211 | if [ ! -e "${output}" ]; then |
| 212 | elog "Output file does not exist." |
| 213 | return 1 |
| 214 | fi |
| 215 | fi |
| 216 | } |
| 217 | |
| 218 | aomenc_av1_ivf() { |
| 219 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 220 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf" |
| 221 | aomenc $(yuv_input_hantro_collage) \ |
| 222 | --codec=av1 \ |
| 223 | --limit="${TEST_FRAMES}" \ |
| 224 | --ivf \ |
| 225 | --output="${output}" |
| 226 | |
| 227 | if [ ! -e "${output}" ]; then |
| 228 | elog "Output file does not exist." |
| 229 | return 1 |
| 230 | fi |
| 231 | fi |
| 232 | } |
| 233 | |
| 234 | aomenc_av1_webm() { |
| 235 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 236 | [ "$(webm_io_available)" = "yes" ]; then |
| 237 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm" |
| 238 | aomenc $(yuv_input_hantro_collage) \ |
| 239 | --codec=av1 \ |
| 240 | --limit="${TEST_FRAMES}" \ |
| 241 | --output="${output}" |
| 242 | |
| 243 | if [ ! -e "${output}" ]; then |
| 244 | elog "Output file does not exist." |
| 245 | return 1 |
| 246 | fi |
| 247 | fi |
| 248 | } |
| 249 | |
| 250 | aomenc_av1_webm_rt() { |
| 251 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 252 | [ "$(webm_io_available)" = "yes" ]; then |
| 253 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt.webm" |
| 254 | aomenc $(yuv_input_hantro_collage) \ |
| 255 | $(aomenc_rt_params av1) \ |
| 256 | --output="${output}" |
| 257 | |
| 258 | if [ ! -e "${output}" ]; then |
| 259 | elog "Output file does not exist." |
| 260 | return 1 |
| 261 | fi |
| 262 | fi |
| 263 | } |
| 264 | |
| 265 | aomenc_av1_webm_rt_multithread_tiled() { |
| 266 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 267 | [ "$(webm_io_available)" = "yes" ]; then |
| 268 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt_multithread_tiled.webm" |
| 269 | local readonly tilethread_min=2 |
| 270 | local readonly tilethread_max=4 |
| 271 | local readonly num_threads="$(seq ${tilethread_min} ${tilethread_max})" |
| 272 | local readonly num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})" |
| 273 | |
| 274 | for threads in ${num_threads}; do |
| 275 | for tile_cols in ${num_tile_cols}; do |
| 276 | aomenc $(y4m_input_720p) \ |
| 277 | $(aomenc_rt_params av1) \ |
| 278 | --threads=${threads} \ |
| 279 | --tile-columns=${tile_cols} \ |
| 280 | --output="${output}" |
| 281 | done |
| 282 | done |
| 283 | |
| 284 | if [ ! -e "${output}" ]; then |
| 285 | elog "Output file does not exist." |
| 286 | return 1 |
| 287 | fi |
| 288 | |
| 289 | rm "${output}" |
| 290 | fi |
| 291 | } |
| 292 | |
| 293 | aomenc_av1_webm_rt_multithread_tiled_frameparallel() { |
| 294 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 295 | [ "$(webm_io_available)" = "yes" ]; then |
| 296 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt_mt_t_fp.webm" |
| 297 | local readonly tilethread_min=2 |
| 298 | local readonly tilethread_max=4 |
| 299 | local readonly num_threads="$(seq ${tilethread_min} ${tilethread_max})" |
| 300 | local readonly num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})" |
| 301 | |
| 302 | for threads in ${num_threads}; do |
| 303 | for tile_cols in ${num_tile_cols}; do |
| 304 | aomenc $(y4m_input_720p) \ |
| 305 | $(aomenc_rt_params av1) \ |
| 306 | --threads=${threads} \ |
| 307 | --tile-columns=${tile_cols} \ |
| 308 | --frame-parallel=1 \ |
| 309 | --output="${output}" |
| 310 | done |
| 311 | done |
| 312 | |
| 313 | if [ ! -e "${output}" ]; then |
| 314 | elog "Output file does not exist." |
| 315 | return 1 |
| 316 | fi |
| 317 | |
| 318 | rm "${output}" |
| 319 | fi |
| 320 | } |
| 321 | |
| 322 | aomenc_av1_webm_2pass() { |
| 323 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 324 | [ "$(webm_io_available)" = "yes" ]; then |
| 325 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm" |
| 326 | aomenc $(yuv_input_hantro_collage) \ |
| 327 | --codec=av1 \ |
| 328 | --limit="${TEST_FRAMES}" \ |
| 329 | --output="${output}" \ |
| 330 | --passes=2 |
| 331 | |
| 332 | if [ ! -e "${output}" ]; then |
| 333 | elog "Output file does not exist." |
| 334 | return 1 |
| 335 | fi |
| 336 | fi |
| 337 | } |
| 338 | |
| 339 | aomenc_av1_ivf_lossless() { |
| 340 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 341 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf" |
| 342 | aomenc $(yuv_input_hantro_collage) \ |
| 343 | --codec=av1 \ |
| 344 | --limit="${TEST_FRAMES}" \ |
| 345 | --ivf \ |
| 346 | --output="${output}" \ |
| 347 | --lossless=1 |
| 348 | |
| 349 | if [ ! -e "${output}" ]; then |
| 350 | elog "Output file does not exist." |
| 351 | return 1 |
| 352 | fi |
| 353 | fi |
| 354 | } |
| 355 | |
| 356 | aomenc_av1_ivf_minq0_maxq0() { |
| 357 | if [ "$(aomenc_can_encode_av1)" = "yes" ]; then |
| 358 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf" |
| 359 | aomenc $(yuv_input_hantro_collage) \ |
| 360 | --codec=av1 \ |
| 361 | --limit="${TEST_FRAMES}" \ |
| 362 | --ivf \ |
| 363 | --output="${output}" \ |
| 364 | --min-q=0 \ |
| 365 | --max-q=0 |
| 366 | |
| 367 | if [ ! -e "${output}" ]; then |
| 368 | elog "Output file does not exist." |
| 369 | return 1 |
| 370 | fi |
| 371 | fi |
| 372 | } |
| 373 | |
| 374 | aomenc_av1_webm_lag10_frames20() { |
| 375 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 376 | [ "$(webm_io_available)" = "yes" ]; then |
| 377 | local readonly lag_total_frames=20 |
| 378 | local readonly lag_frames=10 |
| 379 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag10_frames20.webm" |
| 380 | aomenc $(yuv_input_hantro_collage) \ |
| 381 | --codec=av1 \ |
| 382 | --limit="${lag_total_frames}" \ |
| 383 | --lag-in-frames="${lag_frames}" \ |
| 384 | --output="${output}" \ |
| 385 | --passes=2 \ |
| 386 | --auto-alt-ref=1 |
| 387 | |
| 388 | if [ ! -e "${output}" ]; then |
| 389 | elog "Output file does not exist." |
| 390 | return 1 |
| 391 | fi |
| 392 | fi |
| 393 | } |
| 394 | |
| 395 | # TODO(fgalligan): Test that DisplayWidth is different than video width. |
| 396 | aomenc_av1_webm_non_square_par() { |
| 397 | if [ "$(aomenc_can_encode_av1)" = "yes" ] && \ |
| 398 | [ "$(webm_io_available)" = "yes" ]; then |
| 399 | local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm" |
| 400 | aomenc $(y4m_input_non_square_par) \ |
| 401 | --codec=av1 \ |
| 402 | --limit="${TEST_FRAMES}" \ |
| 403 | --output="${output}" |
| 404 | |
| 405 | if [ ! -e "${output}" ]; then |
| 406 | elog "Output file does not exist." |
| 407 | return 1 |
| 408 | fi |
| 409 | fi |
| 410 | } |
| 411 | |
| 412 | aomenc_tests="aomenc_vp8_ivf |
| 413 | aomenc_vp8_webm |
| 414 | aomenc_vp8_webm_rt |
| 415 | aomenc_vp8_webm_2pass |
| 416 | aomenc_vp8_webm_lag10_frames20 |
| 417 | aomenc_vp8_ivf_piped_input |
| 418 | aomenc_av1_ivf |
| 419 | aomenc_av1_webm |
| 420 | aomenc_av1_webm_rt |
| 421 | aomenc_av1_webm_rt_multithread_tiled |
| 422 | aomenc_av1_webm_rt_multithread_tiled_frameparallel |
| 423 | aomenc_av1_webm_2pass |
| 424 | aomenc_av1_ivf_lossless |
| 425 | aomenc_av1_ivf_minq0_maxq0 |
| 426 | aomenc_av1_webm_lag10_frames20 |
| 427 | aomenc_av1_webm_non_square_par" |
| 428 | |
| 429 | run_tests aomenc_verify_environment "${aomenc_tests}" |