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 aomdec. To add new tests to this file, do the following: |
| 12 | ## 1. Write a shell function (this is your test). |
| 13 | ## 2. Add the function to aomdec_tests (on a new line). |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | ## |
| 15 | . $(dirname $0)/tools_common.sh |
| 16 | |
| 17 | # Environment check: Make sure input is available. |
| 18 | aomdec_verify_environment() { |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 19 | if [ "$(av1_encode_available)" != "yes" ] ; then |
| 20 | if [ ! -e "${AV1_WEBM_FILE}" ] || \ |
| 21 | [ ! -e "${AV1_FPM_WEBM_FILE}" ] || \ |
| 22 | [ ! -e "${AV1_LT_50_FRAMES_WEBM_FILE}" ] ; then |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 23 | elog "Libaom test data must exist in LIBAOM_TEST_DATA_PATH." |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 24 | return 1 |
| 25 | fi |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 26 | fi |
| 27 | if [ -z "$(aom_tool_path aomdec)" ]; then |
| 28 | elog "aomdec not found. It must exist in LIBAOM_BIN_PATH or its parent." |
| 29 | return 1 |
| 30 | fi |
| 31 | } |
| 32 | |
| 33 | # Wrapper function for running aomdec with pipe input. Requires that |
| 34 | # LIBAOM_BIN_PATH points to the directory containing aomdec. $1 is used as the |
| 35 | # input file path and shifted away. All remaining parameters are passed through |
| 36 | # to aomdec. |
| 37 | aomdec_pipe() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 38 | local readonly input="$1" |
| 39 | shift |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 40 | if [ ! -e "${input}" ]; then |
| 41 | local file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf" |
| 42 | encode_yuv_raw_input_av1 "${file}" --ivf |
| 43 | else |
| 44 | local file="${input}" |
| 45 | fi |
| 46 | cat "${file}" | aomdec - "$@" ${devnull} |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 49 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 50 | # Wrapper function for running aomdec. Requires that LIBAOM_BIN_PATH points to |
| 51 | # the directory containing aomdec. $1 one is used as the input file path and |
| 52 | # shifted away. All remaining parameters are passed through to aomdec. |
| 53 | aomdec() { |
| 54 | local readonly decoder="$(aom_tool_path aomdec)" |
| 55 | local readonly input="$1" |
| 56 | shift |
| 57 | eval "${AOM_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull} |
| 58 | } |
| 59 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 60 | aomdec_can_decode_av1() { |
| 61 | if [ "$(av1_decode_available)" = "yes" ]; then |
| 62 | echo yes |
| 63 | fi |
| 64 | } |
| 65 | |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 66 | aomdec_aom_ivf_pipe_input() { |
| 67 | if [ "$(aomdec_can_decode_av1)" = "yes" ]; then |
| 68 | aomdec_pipe "${AOM_IVF_FILE}" --summary --noblit |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 69 | fi |
| 70 | } |
| 71 | |
| 72 | aomdec_av1_webm() { |
| 73 | if [ "$(aomdec_can_decode_av1)" = "yes" ] && \ |
| 74 | [ "$(webm_io_available)" = "yes" ]; then |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 75 | if [ ! -e "${AV1_WEBM_FILE}" ]; then |
| 76 | local file="${AOM_TEST_OUTPUT_DIR}/test_encode.webm" |
| 77 | encode_yuv_raw_input_av1 "${file}" |
| 78 | else |
| 79 | aomdec "${AV1_WEBM_FILE}" --summary --noblit |
| 80 | fi |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 81 | fi |
| 82 | } |
| 83 | |
| 84 | aomdec_av1_webm_frame_parallel() { |
| 85 | if [ "$(aomdec_can_decode_av1)" = "yes" ] && \ |
| 86 | [ "$(webm_io_available)" = "yes" ]; then |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 87 | local file |
| 88 | if [ ! -e "${AV1_WEBM_FILE}" ]; then |
| 89 | file="${AOM_TEST_OUTPUT_DIR}/test_encode.webm" |
| 90 | encode_yuv_raw_input_av1 "${file}" "--ivf --error-resilient=1 " |
| 91 | else |
| 92 | file="${AV1_FPM_WEBM_FILE}" |
| 93 | fi |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 94 | for threads in 2 3 4 5 6 7 8; do |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 95 | aomdec "${file}" --summary --noblit --threads=$threads \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 96 | --frame-parallel |
| 97 | done |
| 98 | fi |
| 99 | } |
| 100 | |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 101 | # TODO(vigneshv): Enable or remove this test and associated code. |
| 102 | DISABLED_aomdec_av1_webm_less_than_50_frames() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 103 | # ensure that reaching eof in webm_guess_framerate doesn't result in invalid |
| 104 | # frames in actual webm_read_frame calls. |
| 105 | if [ "$(aomdec_can_decode_av1)" = "yes" ] && \ |
| 106 | [ "$(webm_io_available)" = "yes" ]; then |
| 107 | local readonly decoder="$(aom_tool_path aomdec)" |
| 108 | local readonly expected=10 |
| 109 | local readonly num_frames=$(${AOM_TEST_PREFIX} "${decoder}" \ |
| 110 | "${AV1_LT_50_FRAMES_WEBM_FILE}" --summary --noblit 2>&1 \ |
| 111 | | awk '/^[0-9]+ decoded frames/ { print $1 }') |
| 112 | if [ "$num_frames" -ne "$expected" ]; then |
| 113 | elog "Output frames ($num_frames) != expected ($expected)" |
| 114 | return 1 |
| 115 | fi |
| 116 | fi |
| 117 | } |
| 118 | |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 119 | aomdec_tests="aomdec_av1_webm |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 120 | aomdec_av1_webm_frame_parallel |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 121 | aomdec_aom_ivf_pipe_input |
| 122 | DISABLED_aomdec_av1_webm_less_than_50_frames" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 123 | |
| 124 | run_tests aomdec_verify_environment "${aomdec_tests}" |