xref: /aosp_15_r20/external/libaom/test/simple_decoder.sh (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
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 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).
15##
16. $(dirname $0)/tools_common.sh
17
18# Environment check: Make sure input is available:
19simple_decoder_verify_environment() {
20  if [ ! "$(av1_encode_available)" = "yes" ] && [ ! -e "${AV1_IVF_FILE}" ]; then
21    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() {
28  local decoder="$(aom_tool_path simple_decoder)"
29  local input_file="$1"
30  local codec="$2"
31  local output_file="${AOM_TEST_OUTPUT_DIR}/simple_decoder_${codec}.raw"
32
33  if [ ! -x "${decoder}" ]; then
34    elog "${decoder} does not exist or is not executable."
35    return 1
36  fi
37
38  eval "${AOM_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
39      ${devnull} || return 1
40
41  [ -e "${output_file}" ] || return 1
42}
43
44simple_decoder_av1() {
45  if [ "$(av1_decode_available)" = "yes" ]; then
46    if [ ! -e "${AV1_IVF_FILE}" ]; then
47      local file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf"
48      encode_yuv_raw_input_av1 "${file}" --ivf
49      simple_decoder "${file}" av1 || return 1
50    else
51      simple_decoder "${AV1_IVF_FILE}" av1 || return 1
52    fi
53  fi
54}
55
56simple_decoder_tests="simple_decoder_av1"
57
58run_tests simple_decoder_verify_environment "${simple_decoder_tests}"
59