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_to_md5 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 decode_to_md5_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_to_md5_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_to_md5 on $1 and captures the md5 sum for the final frame. $2 is 27*77c1e3ccSAndroid Build Coastguard Worker# interpreted as codec name and used solely to name the output file. $3 is the 28*77c1e3ccSAndroid Build Coastguard Worker# expected md5 sum: It must match that of the final frame. 29*77c1e3ccSAndroid Build Coastguard Workerdecode_to_md5() { 30*77c1e3ccSAndroid Build Coastguard Worker local decoder="$(aom_tool_path decode_to_md5)" 31*77c1e3ccSAndroid Build Coastguard Worker local input_file="$1" 32*77c1e3ccSAndroid Build Coastguard Worker local codec="$2" 33*77c1e3ccSAndroid Build Coastguard Worker local expected_md5="$3" 34*77c1e3ccSAndroid Build Coastguard Worker local output_file="${AOM_TEST_OUTPUT_DIR}/decode_to_md5_${codec}" 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 ${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 local md5_last_frame="$(tail -n1 "${output_file}" | awk '{print $1}')" 47*77c1e3ccSAndroid Build Coastguard Worker local actual_md5="$(echo "${md5_last_frame}" | awk '{print $1}')" 48*77c1e3ccSAndroid Build Coastguard Worker if [ "${actual_md5}" = "${expected_md5}" ]; then 49*77c1e3ccSAndroid Build Coastguard Worker return 0 50*77c1e3ccSAndroid Build Coastguard Worker else 51*77c1e3ccSAndroid Build Coastguard Worker elog "MD5 mismatch:" 52*77c1e3ccSAndroid Build Coastguard Worker elog "Expected: ${expected_md5}" 53*77c1e3ccSAndroid Build Coastguard Worker elog "Actual: ${actual_md5}" 54*77c1e3ccSAndroid Build Coastguard Worker return 1 55*77c1e3ccSAndroid Build Coastguard Worker fi 56*77c1e3ccSAndroid Build Coastguard Worker} 57*77c1e3ccSAndroid Build Coastguard Worker 58*77c1e3ccSAndroid Build Coastguard WorkerDISABLED_decode_to_md5_av1() { 59*77c1e3ccSAndroid Build Coastguard Worker # expected MD5 sum for the last frame. 60*77c1e3ccSAndroid Build Coastguard Worker local expected_md5="567dd6d4b7a7170edddbf58bbcc3aff1" 61*77c1e3ccSAndroid Build Coastguard Worker local file="${AV1_IVF_FILE}" 62*77c1e3ccSAndroid Build Coastguard Worker 63*77c1e3ccSAndroid Build Coastguard Worker # TODO(urvang): Check in the encoded file (like libvpx does) to avoid 64*77c1e3ccSAndroid Build Coastguard Worker # encoding every time. 65*77c1e3ccSAndroid Build Coastguard Worker if [ "$(av1_decode_available)" = "yes" ]; then 66*77c1e3ccSAndroid Build Coastguard Worker if [ ! -e "${AV1_IVF_FILE}" ]; then 67*77c1e3ccSAndroid Build Coastguard Worker file="${AOM_TEST_OUTPUT_DIR}/test_encode.ivf" 68*77c1e3ccSAndroid Build Coastguard Worker encode_yuv_raw_input_av1 "${file}" --ivf || return 1 69*77c1e3ccSAndroid Build Coastguard Worker fi 70*77c1e3ccSAndroid Build Coastguard Worker decode_to_md5 "${file}" "av1" "${expected_md5}" 71*77c1e3ccSAndroid Build Coastguard Worker fi 72*77c1e3ccSAndroid Build Coastguard Worker} 73*77c1e3ccSAndroid Build Coastguard Worker 74*77c1e3ccSAndroid Build Coastguard Worker# TODO(tomfinegan): Enable when the bitstream stabilizes. 75*77c1e3ccSAndroid Build Coastguard Workerdecode_to_md5_tests="DISABLED_decode_to_md5_av1" 76*77c1e3ccSAndroid Build Coastguard Worker 77*77c1e3ccSAndroid Build Coastguard Workerrun_tests decode_to_md5_verify_environment "${decode_to_md5_tests}" 78