1#!/bin/sh 2## Copyright (c) 2018, 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 lightfield example. 12## 13. $(dirname $0)/tools_common.sh 14 15# Environment check: $infile is required. 16lightfield_test_verify_environment() { 17 local infile="${LIBAOM_TEST_DATA_PATH}/vase10x10.yuv" 18 if [ ! -e "${infile}" ]; then 19 echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH." 20 return 1 21 fi 22} 23 24# Run the lightfield example 25lightfield_test() { 26 local img_width=1024 27 local img_height=1024 28 local lf_width=10 29 local lf_height=10 30 local lf_blocksize=5 31 local num_references=4 32 local num_tile_lists=2 33 34 # Encode the lightfield. 35 local encoder="${LIBAOM_BIN_PATH}/lightfield_encoder${AOM_TEST_EXE_SUFFIX}" 36 local yuv_file="${LIBAOM_TEST_DATA_PATH}/vase10x10.yuv" 37 local lf_file="${AOM_TEST_OUTPUT_DIR}/vase10x10.ivf" 38 if [ ! -x "${encoder}" ]; then 39 elog "${encoder} does not exist or is not executable." 40 return 1 41 fi 42 43 eval "${AOM_TEST_PREFIX}" "${encoder}" "${img_width}" "${img_height}" \ 44 "${yuv_file}" "${lf_file}" "${lf_width}" \ 45 "${lf_height}" "${lf_blocksize}" ${devnull} || return 1 46 47 [ -e "${lf_file}" ] || return 1 48 49 # Check to ensure all camera frames have the identical frame header. If not identical, this test fails. 50 for i in ./fh*; do 51 diff ./fh004 $i > /dev/null 52 if [ $? -eq 1 ]; then 53 return 1 54 fi 55 done 56 57 # Check to ensure all camera frames use the identical frame context. If not identical, this test fails. 58 for i in ./fc*; do 59 diff ./fc004 $i > /dev/null 60 if [ $? -eq 1 ]; then 61 return 1 62 fi 63 done 64 65 # Parse lightfield bitstream to construct and output a new bitstream that can 66 # be decoded by an AV1 decoder. 67 local bs_decoder="${LIBAOM_BIN_PATH}/lightfield_bitstream_parsing${AOM_TEST_EXE_SUFFIX}" 68 local tl_file="${AOM_TEST_OUTPUT_DIR}/vase_tile_list.ivf" 69 local tl_text_file="${LIBAOM_TEST_DATA_PATH}/vase10x10_tiles.txt" 70 if [ ! -x "${bs_decoder}" ]; then 71 elog "${bs_decoder} does not exist or is not executable." 72 return 1 73 fi 74 75 eval "${AOM_TEST_PREFIX}" "${bs_decoder}" "${lf_file}" "${tl_file}" \ 76 "${num_references}" "${tl_text_file}" ${devnull} || return 1 77 78 [ -e "${tl_file}" ] || return 1 79 80 # Run lightfield tile list decoder 81 local tl_decoder="${LIBAOM_BIN_PATH}/lightfield_tile_list_decoder${AOM_TEST_EXE_SUFFIX}" 82 local tl_outfile="${AOM_TEST_OUTPUT_DIR}/vase_tile_list.yuv" 83 if [ ! -x "${tl_decoder}" ]; then 84 elog "${tl_decoder} does not exist or is not executable." 85 return 1 86 fi 87 88 eval "${AOM_TEST_PREFIX}" "${tl_decoder}" "${tl_file}" "${tl_outfile}" \ 89 "${num_references}" "${num_tile_lists}" ${devnull} || return 1 90 91 [ -e "${tl_outfile}" ] || return 1 92 93 # Run reference lightfield decoder 94 local ref_decoder="${LIBAOM_BIN_PATH}/lightfield_decoder${AOM_TEST_EXE_SUFFIX}" 95 local tl_reffile="${AOM_TEST_OUTPUT_DIR}/vase_reference.yuv" 96 if [ ! -x "${ref_decoder}" ]; then 97 elog "${ref_decoder} does not exist or is not executable." 98 return 1 99 fi 100 101 eval "${AOM_TEST_PREFIX}" "${ref_decoder}" "${lf_file}" "${tl_reffile}" \ 102 "${num_references}" "${tl_text_file}" ${devnull} || return 1 103 104 [ -e "${tl_reffile}" ] || return 1 105 106 # Check if tl_outfile and tl_reffile are identical. If not identical, this test fails. 107 diff ${tl_outfile} ${tl_reffile} > /dev/null 108 if [ $? -eq 1 ]; then 109 return 1 110 fi 111} 112 113lightfield_test_tests="lightfield_test" 114 115run_tests lightfield_test_verify_environment "${lightfield_test_tests}" 116