Merge "Cleaning up vp9_full_search_sadx8() function."
[platform/upstream/libvpx.git] / test / decode_with_drops.sh
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   [ -x "${decoder}" ] || return 1
38
39   "${decoder}" "${input_file}" "${output_file}" "${drop_mode}" > /dev/null 2>&1
40
41   [ -e "${output_file}" ] || return 1
42 }
43
44 # Decodes $VP8_IVF_FILE while dropping frames, twice: once in sequence mode,
45 # and once in pattern mode.
46 # Note: This test assumes that $VP8_IVF_FILE has exactly 29 frames, and could
47 # break if the file is modified.
48 decode_with_drops_vp8() {
49   if [ "$(vp8_decode_available)" = "yes" ]; then
50     # Test sequence mode: Drop frames 2-28.
51     decode_with_drops "${VP8_IVF_FILE}" "vp8" "2-28"
52
53     # Test pattern mode: Drop 3 of every 4 frames.
54     decode_with_drops "${VP8_IVF_FILE}" "vp8" "3/4"
55   fi
56 }
57
58 # Decodes $VP9_IVF_FILE while dropping frames, twice: once in sequence mode,
59 # and once in pattern mode.
60 # Note: This test assumes that $VP9_IVF_FILE has exactly 20 frames, and could
61 # break if the file is modified.
62 decode_with_drops_vp9() {
63   if [ "$(vp9_decode_available)" = "yes" ]; then
64     # Test sequence mode: Drop frames 2-28.
65     decode_with_drops "${VP9_IVF_FILE}" "vp9" "2-19"
66
67     # Test pattern mode: Drop 3 of every 4 frames.
68     decode_with_drops "${VP9_IVF_FILE}" "vp9" "3/4"
69   fi
70 }
71
72 decode_with_drops_tests="decode_with_drops_vp8
73                          decode_with_drops_vp9"
74
75 run_tests decode_with_drops_verify_environment "${decode_with_drops_tests}"