1 #!/bin/sh 2 ## 3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved. 4 ## 5 ## Use of this source code is governed by a BSD-style license 6 ## that can be found in the LICENSE file in the root of the source 7 ## tree. An additional intellectual property rights grant can be found 8 ## in the file PATENTS. All contributing project authors may 9 ## be found in the AUTHORS file in the root of the source tree. 10 ## 11 ## This file tests the libvpx decode_with_drops example. To add new tests to 12 ## this file, do the following: 13 ## 1. Write a shell function (this is your test). 14 ## 2. Add the function to decode_with_drops_tests (on a new line). 15 ## 16 . $(dirname $0)/tools_common.sh 17 18 # Environment check: Make sure input is available: 19 # $VP8_IVF_FILE and $VP9_IVF_FILE are required. 20 decode_with_drops_verify_environment() { 21 if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_IVF_FILE}" ]; then 22 echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." 23 return 1 24 fi 25 } 26 27 # Runs decode_with_drops on $1, $2 is interpreted as codec name and used solely 28 # to name the output file. $3 is the drop mode, and is passed directly to 29 # decode_with_drops. 30 decode_with_drops() { 31 local decoder="${LIBVPX_BIN_PATH}/decode_with_drops${VPX_TEST_EXE_SUFFIX}" 32 local input_file="$1" 33 local codec="$2" 34 local output_file="${VPX_TEST_OUTPUT_DIR}/decode_with_drops_${codec}" 35 local drop_mode="$3" 36 37 if [ ! -x "${decoder}" ]; then 38 elog "${decoder} does not exist or is not executable." 39 return 1 40 fi 41 42 eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ 43 "${drop_mode}" ${devnull} 44 45 [ -e "${output_file}" ] || return 1 46 } 47 48 # Decodes $VP8_IVF_FILE while dropping frames, twice: once in sequence mode, 49 # and once in pattern mode. 50 # Note: This test assumes that $VP8_IVF_FILE has exactly 29 frames, and could 51 # break if the file is modified. 52 decode_with_drops_vp8() { 53 if [ "$(vp8_decode_available)" = "yes" ]; then 54 # Test sequence mode: Drop frames 2-28. 55 decode_with_drops "${VP8_IVF_FILE}" "vp8" "2-28" 56 57 # Test pattern mode: Drop 3 of every 4 frames. 58 decode_with_drops "${VP8_IVF_FILE}" "vp8" "3/4" 59 fi 60 } 61 62 # Decodes $VP9_IVF_FILE while dropping frames, twice: once in sequence mode, 63 # and once in pattern mode. 64 # Note: This test assumes that $VP9_IVF_FILE has exactly 20 frames, and could 65 # break if the file is modified. 66 decode_with_drops_vp9() { 67 if [ "$(vp9_decode_available)" = "yes" ]; then 68 # Test sequence mode: Drop frames 2-28. 69 decode_with_drops "${VP9_IVF_FILE}" "vp9" "2-19" 70 71 # Test pattern mode: Drop 3 of every 4 frames. 72 decode_with_drops "${VP9_IVF_FILE}" "vp9" "3/4" 73 fi 74 } 75 76 decode_with_drops_tests="decode_with_drops_vp8 77 decode_with_drops_vp9" 78 79 run_tests decode_with_drops_verify_environment "${decode_with_drops_tests}" 80