aomdec.sh 3.67 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#!/bin/sh
##
##  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
##
Adrian Grange's avatar
Adrian Grange committed
11
##  This file tests aomdec. To add new tests to this file, do the following:
12
##    1. Write a shell function (this is your test).
Adrian Grange's avatar
Adrian Grange committed
13
##    2. Add the function to aomdec_tests (on a new line).
14
15
16
17
##
. $(dirname $0)/tools_common.sh

# Environment check: Make sure input is available.
Adrian Grange's avatar
Adrian Grange committed
18
aomdec_verify_environment() {
Adrian Grange's avatar
Adrian Grange committed
19
20
21
  if [ ! -e "${AOM_IVF_FILE}" ] || [ ! -e "${AV1_WEBM_FILE}" ] || \
    [ ! -e "${AV1_FPM_WEBM_FILE}" ] || \
    [ ! -e "${AV1_LT_50_FRAMES_WEBM_FILE}" ] ; then
Adrian Grange's avatar
Adrian Grange committed
22
    elog "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
23
24
    return 1
  fi
Adrian Grange's avatar
Adrian Grange committed
25
26
  if [ -z "$(aom_tool_path aomdec)" ]; then
    elog "aomdec not found. It must exist in LIBAOM_BIN_PATH or its parent."
27
28
    return 1
  fi
29
30
}

Adrian Grange's avatar
Adrian Grange committed
31
32
# Wrapper function for running aomdec with pipe input. Requires that
# LIBAOM_BIN_PATH points to the directory containing aomdec. $1 is used as the
Tom Finegan's avatar
Tom Finegan committed
33
# input file path and shifted away. All remaining parameters are passed through
Adrian Grange's avatar
Adrian Grange committed
34
35
36
# to aomdec.
aomdec_pipe() {
  local readonly decoder="$(aom_tool_path aomdec)"
Tom Finegan's avatar
Tom Finegan committed
37
  local readonly input="$1"
Tom Finegan's avatar
Tom Finegan committed
38
  shift
Adrian Grange's avatar
Adrian Grange committed
39
  cat "${input}" | eval "${AOM_TEST_PREFIX}" "${decoder}" - "$@" ${devnull}
Tom Finegan's avatar
Tom Finegan committed
40
}
41

Adrian Grange's avatar
Adrian Grange committed
42
43
44
45
46
# Wrapper function for running aomdec. Requires that LIBAOM_BIN_PATH points to
# the directory containing aomdec. $1 one is used as the input file path and
# shifted away. All remaining parameters are passed through to aomdec.
aomdec() {
  local readonly decoder="$(aom_tool_path aomdec)"
Tom Finegan's avatar
Tom Finegan committed
47
  local readonly input="$1"
Tom Finegan's avatar
Tom Finegan committed
48
  shift
Adrian Grange's avatar
Adrian Grange committed
49
  eval "${AOM_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull}
50
51
}

Adrian Grange's avatar
Adrian Grange committed
52
53
aomdec_can_decode_aom() {
  if [ "$(aom_decode_available)" = "yes" ]; then
54
55
56
57
    echo yes
  fi
}

Adrian Grange's avatar
Adrian Grange committed
58
59
aomdec_can_decode_av1() {
  if [ "$(av1_decode_available)" = "yes" ]; then
60
61
62
63
    echo yes
  fi
}

Adrian Grange's avatar
Adrian Grange committed
64
65
aomdec_aom_ivf() {
  if [ "$(aomdec_can_decode_aom)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
66
    aomdec "${AOM_IVF_FILE}" --summary --noblit
67
68
69
  fi
}

Adrian Grange's avatar
Adrian Grange committed
70
71
aomdec_aom_ivf_pipe_input() {
  if [ "$(aomdec_can_decode_aom)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
72
    aomdec_pipe "${AOM_IVF_FILE}" --summary --noblit
73
74
75
  fi
}

Adrian Grange's avatar
Adrian Grange committed
76
77
aomdec_av1_webm() {
  if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
78
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
79
    aomdec "${AV1_WEBM_FILE}" --summary --noblit
80
81
82
  fi
}

Adrian Grange's avatar
Adrian Grange committed
83
84
aomdec_av1_webm_frame_parallel() {
  if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
85
86
     [ "$(webm_io_available)" = "yes" ]; then
    for threads in 2 3 4 5 6 7 8; do
Adrian Grange's avatar
Adrian Grange committed
87
      aomdec "${AV1_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \
88
89
90
        --frame-parallel
    done
  fi
91
}
92

Adrian Grange's avatar
Adrian Grange committed
93
aomdec_av1_webm_less_than_50_frames() {
94
95
  # ensure that reaching eof in webm_guess_framerate doesn't result in invalid
  # frames in actual webm_read_frame calls.
Adrian Grange's avatar
Adrian Grange committed
96
  if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
97
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
98
    local readonly decoder="$(aom_tool_path aomdec)"
99
    local readonly expected=10
Adrian Grange's avatar
Adrian Grange committed
100
    local readonly num_frames=$(${AOM_TEST_PREFIX} "${decoder}" \
Adrian Grange's avatar
Adrian Grange committed
101
      "${AV1_LT_50_FRAMES_WEBM_FILE}" --summary --noblit 2>&1 \
102
103
104
105
106
      | awk '/^[0-9]+ decoded frames/ { print $1 }')
    if [ "$num_frames" -ne "$expected" ]; then
      elog "Output frames ($num_frames) != expected ($expected)"
      return 1
    fi
107
  fi
108
109
}

Adrian Grange's avatar
Adrian Grange committed
110
111
aomdec_tests="aomdec_aom_ivf
              aomdec_aom_ivf_pipe_input
Adrian Grange's avatar
Adrian Grange committed
112
113
114
              aomdec_av1_webm
              aomdec_av1_webm_frame_parallel
              aomdec_av1_webm_less_than_50_frames"
115

Adrian Grange's avatar
Adrian Grange committed
116
run_tests aomdec_verify_environment "${aomdec_tests}"