blob: 927142287c38f8230ddc43189646702fae96a0ac [file] [log] [blame]
Yaowu Xuf883b422016-08-30 14:01:10 -07001#!/bin/sh
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002## Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuf883b422016-08-30 14:01:10 -07003##
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004## 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 Xuf883b422016-08-30 14:01:10 -070010##
Yaowu Xu9c01aa12016-09-01 14:32:49 -070011## 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 Xuf883b422016-08-30 14:01:10 -070014##
15. $(dirname $0)/tools_common.sh
16
17# Environment check: Make sure input is available.
18aomdec_verify_environment() {
Jim Bankoskif7f04372016-05-27 14:31:29 -070019 if [ "$(av1_encode_available)" != "yes" ] ; then
Tom Finegan8ab44142018-04-27 14:57:52 -070020 if [ ! -e "${AV1_IVF_FILE}" ] || \
21 [ ! -e "${AV1_OBU_ANNEXB_FILE}" ] || \
22 [ ! -e "${AV1_OBU_SEC5_FILE}" ] || \
23 [ ! -e "${AV1_WEBM_FILE}" ]; then
24 elog "Libaom test data must exist before running this test script when " \
25 " encoding is disabled. "
Jim Bankoskif7f04372016-05-27 14:31:29 -070026 return 1
27 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070028 fi
29 if [ -z "$(aom_tool_path aomdec)" ]; then
30 elog "aomdec not found. It must exist in LIBAOM_BIN_PATH or its parent."
31 return 1
32 fi
33}
34
35# Wrapper function for running aomdec with pipe input. Requires that
36# LIBAOM_BIN_PATH points to the directory containing aomdec. $1 is used as the
37# input file path and shifted away. All remaining parameters are passed through
38# to aomdec.
39aomdec_pipe() {
Tom Fineganef64ee82018-07-10 11:35:40 -070040 local input="$1"
Yaowu Xuf883b422016-08-30 14:01:10 -070041 shift
Jim Bankoskif7f04372016-05-27 14:31:29 -070042 if [ ! -e "${input}" ]; then
Tom Finegan8ab44142018-04-27 14:57:52 -070043 elog "Input file ($input) missing in aomdec_pipe()"
44 return 1
Jim Bankoskif7f04372016-05-27 14:31:29 -070045 fi
46 cat "${file}" | aomdec - "$@" ${devnull}
Yaowu Xuf883b422016-08-30 14:01:10 -070047}
48
Jim Bankoskif7f04372016-05-27 14:31:29 -070049
Yaowu Xuf883b422016-08-30 14:01:10 -070050# 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.
53aomdec() {
Tom Fineganef64ee82018-07-10 11:35:40 -070054 local decoder="$(aom_tool_path aomdec)"
55 local input="$1"
Yaowu Xuf883b422016-08-30 14:01:10 -070056 shift
57 eval "${AOM_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull}
58}
59
Yaowu Xuf883b422016-08-30 14:01:10 -070060aomdec_can_decode_av1() {
61 if [ "$(av1_decode_available)" = "yes" ]; then
62 echo yes
63 fi
64}
65
Tom Finegan8ab44142018-04-27 14:57:52 -070066aomdec_av1_ivf() {
Jim Bankoskif7f04372016-05-27 14:31:29 -070067 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -070068 local file="${AV1_IVF_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -070069 if [ ! -e "${file}" ]; then
70 encode_yuv_raw_input_av1 "${file}" --ivf
Jim Bankoskif7f04372016-05-27 14:31:29 -070071 fi
Tom Finegan8ab44142018-04-27 14:57:52 -070072 aomdec "${AV1_IVF_FILE}" --summary --noblit
Yaowu Xuf883b422016-08-30 14:01:10 -070073 fi
74}
75
Tom Finegan8ab44142018-04-27 14:57:52 -070076aomdec_av1_ivf_error_resilient() {
77 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -070078 local file="av1.error-resilient.ivf"
Tom Finegan8ab44142018-04-27 14:57:52 -070079 if [ ! -e "${file}" ]; then
80 encode_yuv_raw_input_av1 "${file}" --ivf --error-resilient=1
81 fi
82 aomdec "${file}" --summary --noblit
83 fi
84}
85
86aomdec_av1_ivf_multithread() {
87 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -070088 local file="${AV1_IVF_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -070089 if [ ! -e "${file}" ]; then
90 encode_yuv_raw_input_av1 "${file}" --ivf
Jim Bankoskif7f04372016-05-27 14:31:29 -070091 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070092 for threads in 2 3 4 5 6 7 8; do
Debargha Mukherjeef9f2d892018-03-08 01:09:36 -080093 aomdec "${file}" --summary --noblit --threads=$threads
Yaowu Xuf883b422016-08-30 14:01:10 -070094 done
95 fi
96}
97
Tom Finegan8ab44142018-04-27 14:57:52 -070098aomdec_aom_ivf_pipe_input() {
99 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -0700100 local file="${AV1_IVF_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -0700101 if [ ! -e "${file}" ]; then
102 encode_yuv_raw_input_av1 "${file}" --ivf
Yaowu Xuf883b422016-08-30 14:01:10 -0700103 fi
Tom Finegan8ab44142018-04-27 14:57:52 -0700104 aomdec_pipe "${AV1_IVF_FILE}" --summary --noblit
Yaowu Xuf883b422016-08-30 14:01:10 -0700105 fi
106}
107
Tom Finegan8ab44142018-04-27 14:57:52 -0700108aomdec_av1_obu_annexb() {
109 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -0700110 local file="${AV1_OBU_ANNEXB_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -0700111 if [ ! -e "${file}" ]; then
112 encode_yuv_raw_input_av1 "${file}" --obu --annexb=1
113 fi
114 aomdec "${file}" --summary --noblit --annexb
115 fi
116}
117
118aomdec_av1_obu_section5() {
119 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -0700120 local file="${AV1_OBU_SEC5_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -0700121 if [ ! -e "${file}" ]; then
122 encode_yuv_raw_input_av1 "${file}" --obu
123 fi
124 aomdec "${file}" --summary --noblit
125 fi
126}
127
128aomdec_av1_webm() {
129 if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
130 [ "$(webm_io_available)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -0700131 local file="${AV1_WEBM_FILE}"
Tom Finegan8ab44142018-04-27 14:57:52 -0700132 if [ ! -e "${file}" ]; then
133 encode_yuv_raw_input_av1 "${file}"
134 fi
135 aomdec "${AV1_WEBM_FILE}" --summary --noblit
136 fi
137}
138
139aomdec_tests="aomdec_av1_ivf
140 aomdec_av1_ivf_error_resilient
141 aomdec_av1_ivf_multithread
Jim Bankoskif7f04372016-05-27 14:31:29 -0700142 aomdec_aom_ivf_pipe_input
Tom Finegan8ab44142018-04-27 14:57:52 -0700143 aomdec_av1_obu_annexb
144 aomdec_av1_obu_section5
145 aomdec_av1_webm"
Yaowu Xuf883b422016-08-30 14:01:10 -0700146
147run_tests aomdec_verify_environment "${aomdec_tests}"