blob: 28901ed1bd30b4ea3376dc3e0a5b95005a441e51 [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
20 if [ ! -e "${AV1_WEBM_FILE}" ] || \
21 [ ! -e "${AV1_FPM_WEBM_FILE}" ] || \
22 [ ! -e "${AV1_LT_50_FRAMES_WEBM_FILE}" ] ; then
Yaowu Xu97aa09f2016-10-12 08:25:39 -070023 elog "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
Jim Bankoskif7f04372016-05-27 14:31:29 -070024 return 1
25 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070026 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.
37aomdec_pipe() {
Yaowu Xuf883b422016-08-30 14:01:10 -070038 local readonly input="$1"
39 shift
Jim Bankoskif7f04372016-05-27 14:31:29 -070040 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 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() {
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 Xuf883b422016-08-30 14:01:10 -070060aomdec_can_decode_av1() {
61 if [ "$(av1_decode_available)" = "yes" ]; then
62 echo yes
63 fi
64}
65
Jim Bankoskif7f04372016-05-27 14:31:29 -070066aomdec_aom_ivf_pipe_input() {
67 if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
68 aomdec_pipe "${AOM_IVF_FILE}" --summary --noblit
Yaowu Xuf883b422016-08-30 14:01:10 -070069 fi
70}
71
72aomdec_av1_webm() {
73 if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
74 [ "$(webm_io_available)" = "yes" ]; then
Jim Bankoskif7f04372016-05-27 14:31:29 -070075 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 Xuf883b422016-08-30 14:01:10 -070081 fi
82}
83
84aomdec_av1_webm_frame_parallel() {
85 if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
86 [ "$(webm_io_available)" = "yes" ]; then
Jim Bankoskif7f04372016-05-27 14:31:29 -070087 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 Xuf883b422016-08-30 14:01:10 -070094 for threads in 2 3 4 5 6 7 8; do
Jim Bankoskif7f04372016-05-27 14:31:29 -070095 aomdec "${file}" --summary --noblit --threads=$threads \
Yaowu Xuf883b422016-08-30 14:01:10 -070096 --frame-parallel
97 done
98 fi
99}
100
Jim Bankoskif7f04372016-05-27 14:31:29 -0700101# TODO(vigneshv): Enable or remove this test and associated code.
102DISABLED_aomdec_av1_webm_less_than_50_frames() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700103 # 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 Bankoskif7f04372016-05-27 14:31:29 -0700119aomdec_tests="aomdec_av1_webm
Yaowu Xuf883b422016-08-30 14:01:10 -0700120 aomdec_av1_webm_frame_parallel
Jim Bankoskif7f04372016-05-27 14:31:29 -0700121 aomdec_aom_ivf_pipe_input
122 DISABLED_aomdec_av1_webm_less_than_50_frames"
Yaowu Xuf883b422016-08-30 14:01:10 -0700123
124run_tests aomdec_verify_environment "${aomdec_tests}"