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 aom_cx_set_ref example. To add new tests to this 12*77c1e3ccSAndroid Build Coastguard Worker## 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 aom_cx_set_ref_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: $YUV_RAW_INPUT is required. 19*77c1e3ccSAndroid Build Coastguard Workeraom_cx_set_ref_verify_environment() { 20*77c1e3ccSAndroid Build Coastguard Worker if [ ! -e "${YUV_RAW_INPUT}" ]; then 21*77c1e3ccSAndroid Build Coastguard Worker echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH." 22*77c1e3ccSAndroid Build Coastguard Worker return 1 23*77c1e3ccSAndroid Build Coastguard Worker fi 24*77c1e3ccSAndroid Build Coastguard Worker} 25*77c1e3ccSAndroid Build Coastguard Worker 26*77c1e3ccSAndroid Build Coastguard Worker# Runs aom_cx_set_ref and updates the reference frame before encoding frame 90. 27*77c1e3ccSAndroid Build Coastguard Worker# $1 is the codec name, which aom_cx_set_ref does not support at present: It's 28*77c1e3ccSAndroid Build Coastguard Worker# currently used only to name the output file. 29*77c1e3ccSAndroid Build Coastguard Worker# TODO(tomfinegan): Pass the codec param once the example is updated to support 30*77c1e3ccSAndroid Build Coastguard Worker# AV1. 31*77c1e3ccSAndroid Build Coastguard Workeraom_set_ref() { 32*77c1e3ccSAndroid Build Coastguard Worker local encoder="${LIBAOM_BIN_PATH}/aom_cx_set_ref${AOM_TEST_EXE_SUFFIX}" 33*77c1e3ccSAndroid Build Coastguard Worker local codec="$1" 34*77c1e3ccSAndroid Build Coastguard Worker local output_file="${AOM_TEST_OUTPUT_DIR}/aom_cx_set_ref_${codec}.ivf" 35*77c1e3ccSAndroid Build Coastguard Worker local ref_frame_num=4 36*77c1e3ccSAndroid Build Coastguard Worker local limit=10 37*77c1e3ccSAndroid Build Coastguard Worker if [ ! -x "${encoder}" ]; then 38*77c1e3ccSAndroid Build Coastguard Worker elog "${encoder} does not exist or is not executable." 39*77c1e3ccSAndroid Build Coastguard Worker return 1 40*77c1e3ccSAndroid Build Coastguard Worker fi 41*77c1e3ccSAndroid Build Coastguard Worker 42*77c1e3ccSAndroid Build Coastguard Worker eval "${AOM_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ 43*77c1e3ccSAndroid Build Coastguard Worker "${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" \ 44*77c1e3ccSAndroid Build Coastguard Worker "${ref_frame_num}" "${limit}" ${devnull} || return 1 45*77c1e3ccSAndroid Build Coastguard Worker 46*77c1e3ccSAndroid Build Coastguard Worker [ -e "${output_file}" ] || return 1 47*77c1e3ccSAndroid Build Coastguard Worker} 48*77c1e3ccSAndroid Build Coastguard Worker 49*77c1e3ccSAndroid Build Coastguard Workeraom_cx_set_ref_av1() { 50*77c1e3ccSAndroid Build Coastguard Worker if [ "$(av1_encode_available)" = "yes" ]; then 51*77c1e3ccSAndroid Build Coastguard Worker aom_set_ref av1 || return 1 52*77c1e3ccSAndroid Build Coastguard Worker fi 53*77c1e3ccSAndroid Build Coastguard Worker} 54*77c1e3ccSAndroid Build Coastguard Worker 55*77c1e3ccSAndroid Build Coastguard Workeraom_cx_set_ref_tests="aom_cx_set_ref_av1" 56*77c1e3ccSAndroid Build Coastguard Worker 57*77c1e3ccSAndroid Build Coastguard Workerrun_tests aom_cx_set_ref_verify_environment "${aom_cx_set_ref_tests}" 58*77c1e3ccSAndroid Build Coastguard Worker 59