xref: /aosp_15_r20/external/libaom/test/simple_decoder.sh (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker#!/bin/sh
2*77c1e3ccSAndroid Build Coastguard Worker## Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker##
4*77c1e3ccSAndroid Build Coastguard Worker## This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker## was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker## Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker##
11*77c1e3ccSAndroid Build Coastguard Worker## This file tests the libaom simple_decoder example code. To add new tests to
12*77c1e3ccSAndroid Build Coastguard Worker## this file, do the following:
13*77c1e3ccSAndroid Build Coastguard Worker##   1. Write a shell function (this is your test).
14*77c1e3ccSAndroid Build Coastguard Worker##   2. Add the function to simple_decoder_tests (on a new line).
15*77c1e3ccSAndroid Build Coastguard Worker##
16*77c1e3ccSAndroid Build Coastguard Worker. $(dirname $0)/tools_common.sh
17*77c1e3ccSAndroid Build Coastguard Worker
18*77c1e3ccSAndroid Build Coastguard Worker# Environment check: Make sure input is available:
19*77c1e3ccSAndroid Build Coastguard Workersimple_decoder_verify_environment() {
20*77c1e3ccSAndroid Build Coastguard Worker  if [ ! "$(av1_encode_available)" = "yes" ] && [ ! -e "${AV1_IVF_FILE}" ]; then
21*77c1e3ccSAndroid Build Coastguard Worker    return 1
22*77c1e3ccSAndroid Build Coastguard Worker  fi
23*77c1e3ccSAndroid Build Coastguard Worker}
24*77c1e3ccSAndroid Build Coastguard Worker
25*77c1e3ccSAndroid Build Coastguard Worker# Runs simple_decoder using $1 as input file. $2 is the codec name, and is used
26*77c1e3ccSAndroid Build Coastguard Worker# solely to name the output file.
27*77c1e3ccSAndroid Build Coastguard Workersimple_decoder() {
28*77c1e3ccSAndroid Build Coastguard Worker  local decoder="$(aom_tool_path simple_decoder)"
29*77c1e3ccSAndroid Build Coastguard Worker  local input_file="$1"
30*77c1e3ccSAndroid Build Coastguard Worker  local codec="$2"
31*77c1e3ccSAndroid Build Coastguard Worker  local output_file="${AOM_TEST_OUTPUT_DIR}/simple_decoder_${codec}.raw"
32*77c1e3ccSAndroid Build Coastguard Worker
33*77c1e3ccSAndroid Build Coastguard Worker  if [ ! -x "${decoder}" ]; then
34*77c1e3ccSAndroid Build Coastguard Worker    elog "${decoder} does not exist or is not executable."
35*77c1e3ccSAndroid Build Coastguard Worker    return 1
36*77c1e3ccSAndroid Build Coastguard Worker  fi
37*77c1e3ccSAndroid Build Coastguard Worker
38*77c1e3ccSAndroid Build Coastguard Worker  eval "${AOM_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
39*77c1e3ccSAndroid Build Coastguard Worker      ${devnull} || return 1
40*77c1e3ccSAndroid Build Coastguard Worker
41*77c1e3ccSAndroid Build Coastguard Worker  [ -e "${output_file}" ] || return 1
42*77c1e3ccSAndroid Build Coastguard Worker}
43*77c1e3ccSAndroid Build Coastguard Worker
44*77c1e3ccSAndroid Build Coastguard Workersimple_decoder_av1() {
45*77c1e3ccSAndroid Build Coastguard Worker  if [ "$(av1_decode_available)" = "yes" ]; then
46*77c1e3ccSAndroid Build Coastguard Worker    if [ ! -e "${AV1_IVF_FILE}" ]; then
47*77c1e3ccSAndroid Build Coastguard Worker      local file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf"
48*77c1e3ccSAndroid Build Coastguard Worker      encode_yuv_raw_input_av1 "${file}" --ivf
49*77c1e3ccSAndroid Build Coastguard Worker      simple_decoder "${file}" av1 || return 1
50*77c1e3ccSAndroid Build Coastguard Worker    else
51*77c1e3ccSAndroid Build Coastguard Worker      simple_decoder "${AV1_IVF_FILE}" av1 || return 1
52*77c1e3ccSAndroid Build Coastguard Worker    fi
53*77c1e3ccSAndroid Build Coastguard Worker  fi
54*77c1e3ccSAndroid Build Coastguard Worker}
55*77c1e3ccSAndroid Build Coastguard Worker
56*77c1e3ccSAndroid Build Coastguard Workersimple_decoder_tests="simple_decoder_av1"
57*77c1e3ccSAndroid Build Coastguard Worker
58*77c1e3ccSAndroid Build Coastguard Workerrun_tests simple_decoder_verify_environment "${simple_decoder_tests}"
59