blob: ac3a07b189d85c362b4f268c5d381040852fb27f [file] [log] [blame]
Tom Finegan0c358d62014-04-24 13:31:43 -07001#!/bin/sh
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002## Copyright (c) 2016, Alliance for Open Media. All rights reserved
Tom Finegan0c358d62014-04-24 13:31:43 -07003##
Yaowu Xu2ab7ff02016-09-02 12:04:54 -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.
Tom Finegan0c358d62014-04-24 13:31:43 -070010##
Yaowu Xu2ab7ff02016-09-02 12:04:54 -070011## This file tests the libaom simple_decoder example code. To add new tests to
12## this file, do the following:
13## 1. Write a shell function (this is your test).
14## 2. Add the function to simple_decoder_tests (on a new line).
Tom Finegan0c358d62014-04-24 13:31:43 -070015##
16. $(dirname $0)/tools_common.sh
17
18# Environment check: Make sure input is available:
Tom Finegan0c358d62014-04-24 13:31:43 -070019simple_decoder_verify_environment() {
Jim Bankoskie78a9642016-05-25 07:02:19 -070020 if [ ! "$(av1_encode_available)" = "yes" ] && [ ! -e "${AV1_IVF_FILE}" ]; then
Tom Finegan0c358d62014-04-24 13:31:43 -070021 return 1
22 fi
23}
24
25# Runs simple_decoder using $1 as input file. $2 is the codec name, and is used
26# solely to name the output file.
27simple_decoder() {
Yaowu Xuf883b422016-08-30 14:01:10 -070028 local decoder="${LIBAOM_BIN_PATH}/simple_decoder${AOM_TEST_EXE_SUFFIX}"
Tom Finegan0c358d62014-04-24 13:31:43 -070029 local input_file="$1"
30 local codec="$2"
Yaowu Xuf883b422016-08-30 14:01:10 -070031 local output_file="${AOM_TEST_OUTPUT_DIR}/simple_decoder_${codec}.raw"
Tom Finegan0c358d62014-04-24 13:31:43 -070032
Tom Finegan12672c22014-06-16 10:57:00 -070033 if [ ! -x "${decoder}" ]; then
34 elog "${decoder} does not exist or is not executable."
35 return 1
36 fi
Tom Finegan0c358d62014-04-24 13:31:43 -070037
Yaowu Xuf883b422016-08-30 14:01:10 -070038 eval "${AOM_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
Tom Finegan926a6f62014-07-10 15:17:05 -070039 ${devnull}
Tom Finegan0c358d62014-04-24 13:31:43 -070040
41 [ -e "${output_file}" ] || return 1
42}
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044simple_decoder_av1() {
45 if [ "$(av1_decode_available)" = "yes" ]; then
Jim Bankoskie78a9642016-05-25 07:02:19 -070046 if [ ! -e "${AV1_IVF_FILE}" ]; then
47 local file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf"
Jim Bankoskif7f04372016-05-27 14:31:29 -070048 encode_yuv_raw_input_av1 "${file}" --ivf
Jim Bankoskie78a9642016-05-25 07:02:19 -070049 simple_decoder "${file}" av1 || return 1
50 else
51 simple_decoder "${AV1_IVF_FILE}" av1 || return 1
52 fi
Tom Finegan0c358d62014-04-24 13:31:43 -070053 fi
54}
55
Jim Bankoskie78a9642016-05-25 07:02:19 -070056simple_decoder_tests="simple_decoder_av1"
Tom Finegan0c358d62014-04-24 13:31:43 -070057
58run_tests simple_decoder_verify_environment "${simple_decoder_tests}"