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. 10## 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). 14## 15. $(dirname $0)/tools_common.sh 16 17AV1_MONOCHROME_B10="${LIBAOM_TEST_DATA_PATH}/av1-1-b10-24-monochrome.ivf" 18AV1_MONOCHROME_B8="${LIBAOM_TEST_DATA_PATH}/av1-1-b8-24-monochrome.ivf" 19 20# Environment check: Make sure input is available. 21aomdec_verify_environment() { 22 if [ "$(av1_encode_available)" != "yes" ] ; then 23 if [ ! -e "${AV1_IVF_FILE}" ] || \ 24 [ ! -e "${AV1_OBU_ANNEXB_FILE}" ] || \ 25 [ ! -e "${AV1_OBU_SEC5_FILE}" ] || \ 26 [ ! -e "${AV1_WEBM_FILE}" ]; then 27 elog "Libaom test data must exist before running this test script when " \ 28 " encoding is disabled. " 29 return 1 30 fi 31 fi 32 if [ ! -e "${AV1_MONOCHROME_B10}" ] || [ ! -e "${AV1_MONOCHROME_B8}" ]; then 33 elog "Libaom test data must exist before running this test script." 34 fi 35 if [ -z "$(aom_tool_path aomdec)" ]; then 36 elog "aomdec not found. It must exist in LIBAOM_BIN_PATH or its parent." 37 return 1 38 fi 39} 40 41# Wrapper function for running aomdec with pipe input. Requires that 42# LIBAOM_BIN_PATH points to the directory containing aomdec. $1 is used as the 43# input file path and shifted away. All remaining parameters are passed through 44# to aomdec. 45aomdec_pipe() { 46 local input="$1" 47 shift 48 if [ ! -e "${input}" ]; then 49 elog "Input file ($input) missing in aomdec_pipe()" 50 return 1 51 fi 52 cat "${file}" | aomdec - "$@" ${devnull} 53} 54 55 56# Wrapper function for running aomdec. Requires that LIBAOM_BIN_PATH points to 57# the directory containing aomdec. $1 one is used as the input file path and 58# shifted away. All remaining parameters are passed through to aomdec. 59aomdec() { 60 local decoder="$(aom_tool_path aomdec)" 61 local input="$1" 62 shift 63 eval "${AOM_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull} 64} 65 66aomdec_can_decode_av1() { 67 if [ "$(av1_decode_available)" = "yes" ]; then 68 echo yes 69 fi 70} 71 72aomdec_av1_ivf() { 73 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 74 local file="${AV1_IVF_FILE}" 75 if [ ! -e "${file}" ]; then 76 encode_yuv_raw_input_av1 "${file}" --ivf || return 1 77 fi 78 aomdec "${AV1_IVF_FILE}" --summary --noblit 79 fi 80} 81 82aomdec_av1_ivf_error_resilient() { 83 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 84 local file="av1.error-resilient.ivf" 85 if [ ! -e "${file}" ]; then 86 encode_yuv_raw_input_av1 "${file}" --ivf --error-resilient=1 || return 1 87 fi 88 aomdec "${file}" --summary --noblit 89 fi 90} 91 92ivf_multithread() { 93 local row_mt="$1" 94 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 95 local file="${AV1_IVF_FILE}" 96 if [ ! -e "${file}" ]; then 97 encode_yuv_raw_input_av1 "${file}" --ivf || return 1 98 fi 99 for threads in 2 3 4 5 6 7 8; do 100 aomdec "${file}" --summary --noblit --threads=$threads --row-mt=$row_mt \ 101 || return 1 102 done 103 fi 104} 105 106aomdec_av1_ivf_multithread() { 107 ivf_multithread 0 # --row-mt=0 108} 109 110aomdec_av1_ivf_multithread_row_mt() { 111 ivf_multithread 1 # --row-mt=1 112} 113 114aomdec_aom_ivf_pipe_input() { 115 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 116 local file="${AV1_IVF_FILE}" 117 if [ ! -e "${file}" ]; then 118 encode_yuv_raw_input_av1 "${file}" --ivf || return 1 119 fi 120 aomdec_pipe "${AV1_IVF_FILE}" --summary --noblit 121 fi 122} 123 124aomdec_av1_obu_annexb() { 125 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 126 local file="${AV1_OBU_ANNEXB_FILE}" 127 if [ ! -e "${file}" ]; then 128 encode_yuv_raw_input_av1 "${file}" --obu --annexb=1 || return 1 129 fi 130 aomdec "${file}" --summary --noblit --annexb 131 fi 132} 133 134aomdec_av1_obu_annexb_pipe_input() { 135 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 136 local file="${AV1_OBU_ANNEXB_FILE}" 137 if [ ! -e "${file}" ]; then 138 encode_yuv_raw_input_av1 "${file}" --obu --annexb=1 || return 1 139 fi 140 aomdec_pipe "${file}" --summary --noblit --annexb 141 fi 142} 143 144aomdec_av1_obu_section5() { 145 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 146 local file="${AV1_OBU_SEC5_FILE}" 147 if [ ! -e "${file}" ]; then 148 encode_yuv_raw_input_av1 "${file}" --obu || return 1 149 fi 150 aomdec "${file}" --summary --noblit 151 fi 152} 153 154aomdec_av1_obu_section5_pipe_input() { 155 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 156 local file="${AV1_OBU_SEC5_FILE}" 157 if [ ! -e "${file}" ]; then 158 encode_yuv_raw_input_av1 "${file}" --obu || return 1 159 fi 160 aomdec_pipe "${file}" --summary --noblit 161 fi 162} 163 164aomdec_av1_webm() { 165 if [ "$(aomdec_can_decode_av1)" = "yes" ] && \ 166 [ "$(webm_io_available)" = "yes" ]; then 167 local file="${AV1_WEBM_FILE}" 168 if [ ! -e "${file}" ]; then 169 encode_yuv_raw_input_av1 "${file}" || return 1 170 fi 171 aomdec "${AV1_WEBM_FILE}" --summary --noblit 172 fi 173} 174 175aomdec_av1_monochrome_yuv() { 176 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then 177 local input="$1" 178 local basename="$(basename "${input}")" 179 local output="${basename}-%wx%h-%4.i420" 180 local md5file="${AOM_TEST_OUTPUT_DIR}/${basename}.md5" 181 local decoder="$(aom_tool_path aomdec)" 182 # Note aomdec() is not used to avoid ${devnull} which may also redirect 183 # stdout. 184 eval "${AOM_TEST_PREFIX}" "${decoder}" --md5 --i420 \ 185 -o "${output}" "${input}" ">" "${md5file}" 2>&1 || return 1 186 diff "${1}.md5" "${md5file}" 187 fi 188} 189 190aomdec_av1_monochrome_yuv_8bit() { 191 aomdec_av1_monochrome_yuv "${AV1_MONOCHROME_B8}" 192} 193 194aomdec_av1_monochrome_yuv_10bit() { 195 aomdec_av1_monochrome_yuv "${AV1_MONOCHROME_B10}" 196} 197 198aomdec_tests="aomdec_av1_ivf 199 aomdec_av1_ivf_multithread 200 aomdec_av1_ivf_multithread_row_mt 201 aomdec_aom_ivf_pipe_input 202 aomdec_av1_monochrome_yuv_8bit" 203 204if [ ! "$(realtime_only_build)" = "yes" ]; then 205 aomdec_tests="${aomdec_tests} 206 aomdec_av1_ivf_error_resilient 207 aomdec_av1_obu_annexb 208 aomdec_av1_obu_section5 209 aomdec_av1_obu_annexb_pipe_input 210 aomdec_av1_obu_section5_pipe_input 211 aomdec_av1_webm" 212fi 213 214if [ "$(highbitdepth_available)" = "yes" ]; then 215 aomdec_tests="${aomdec_tests} 216 aomdec_av1_monochrome_yuv_10bit" 217fi 218 219run_tests aomdec_verify_environment "${aomdec_tests}" 220