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 decode_with_drops example. 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 decode_with_drops_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 Worker# $AV1_IVF_FILE is required. 20*77c1e3ccSAndroid Build Coastguard Workerdecode_with_drops_verify_environment() { 21*77c1e3ccSAndroid Build Coastguard Worker if [ "$(av1_encode_available)" != "yes" ] && [ ! -e "${AV1_IVF_FILE}" ]; then 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 decode_with_drops on $1, $2 is interpreted as codec name and used solely 27*77c1e3ccSAndroid Build Coastguard Worker# to name the output file. $3 is the drop mode, and is passed directly to 28*77c1e3ccSAndroid Build Coastguard Worker# decode_with_drops. 29*77c1e3ccSAndroid Build Coastguard Workerdecode_with_drops() { 30*77c1e3ccSAndroid Build Coastguard Worker local decoder="$(aom_tool_path decode_with_drops)" 31*77c1e3ccSAndroid Build Coastguard Worker local input_file="$1" 32*77c1e3ccSAndroid Build Coastguard Worker local codec="$2" 33*77c1e3ccSAndroid Build Coastguard Worker local output_file="${AOM_TEST_OUTPUT_DIR}/decode_with_drops_${codec}" 34*77c1e3ccSAndroid Build Coastguard Worker local drop_mode="$3" 35*77c1e3ccSAndroid Build Coastguard Worker 36*77c1e3ccSAndroid Build Coastguard Worker if [ ! -x "${decoder}" ]; then 37*77c1e3ccSAndroid Build Coastguard Worker elog "${decoder} does not exist or is not executable." 38*77c1e3ccSAndroid Build Coastguard Worker return 1 39*77c1e3ccSAndroid Build Coastguard Worker fi 40*77c1e3ccSAndroid Build Coastguard Worker 41*77c1e3ccSAndroid Build Coastguard Worker eval "${AOM_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ 42*77c1e3ccSAndroid Build Coastguard Worker "${drop_mode}" ${devnull} || return 1 43*77c1e3ccSAndroid Build Coastguard Worker 44*77c1e3ccSAndroid Build Coastguard Worker [ -e "${output_file}" ] || return 1 45*77c1e3ccSAndroid Build Coastguard Worker} 46*77c1e3ccSAndroid Build Coastguard Worker 47*77c1e3ccSAndroid Build Coastguard Worker 48*77c1e3ccSAndroid Build Coastguard Worker# Decodes $AV1_IVF_FILE while dropping frames, twice: once in sequence mode, 49*77c1e3ccSAndroid Build Coastguard Worker# and once in pattern mode. 50*77c1e3ccSAndroid Build Coastguard WorkerDISABLED_decode_with_drops_av1() { 51*77c1e3ccSAndroid Build Coastguard Worker if [ "$(av1_decode_available)" = "yes" ]; then 52*77c1e3ccSAndroid Build Coastguard Worker local file="${AV1_IVF_FILE}" 53*77c1e3ccSAndroid Build Coastguard Worker if [ ! -e "${AV1_IVF_FILE}" ]; then 54*77c1e3ccSAndroid Build Coastguard Worker file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf" 55*77c1e3ccSAndroid Build Coastguard Worker encode_yuv_raw_input_av1 "${file}" --ivf || return 1 56*77c1e3ccSAndroid Build Coastguard Worker fi 57*77c1e3ccSAndroid Build Coastguard Worker # Drop frames 3 and 4. 58*77c1e3ccSAndroid Build Coastguard Worker decode_with_drops "${file}" "av1" "3-4" || return 1 59*77c1e3ccSAndroid Build Coastguard Worker 60*77c1e3ccSAndroid Build Coastguard Worker # Test pattern mode: Drop 3 of every 4 frames. 61*77c1e3ccSAndroid Build Coastguard Worker decode_with_drops "${file}" "av1" "3/4" || return 1 62*77c1e3ccSAndroid Build Coastguard Worker fi 63*77c1e3ccSAndroid Build Coastguard Worker} 64*77c1e3ccSAndroid Build Coastguard Worker 65*77c1e3ccSAndroid Build Coastguard Worker# TODO(yaowu): Disable this test as trailing_bit check is expected to fail 66*77c1e3ccSAndroid Build Coastguard Workerdecode_with_drops_tests="DISABLED_decode_with_drops_av1" 67*77c1e3ccSAndroid Build Coastguard Worker 68*77c1e3ccSAndroid Build Coastguard Workerrun_tests decode_with_drops_verify_environment "${decode_with_drops_tests}" 69