OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 ## | 2 ## |
3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved. |
4 ## | 4 ## |
5 ## Use of this source code is governed by a BSD-style license | 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 | 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 | 7 ## tree. An additional intellectual property rights grant can be found |
8 ## in the file PATENTS. All contributing project authors may | 8 ## in the file PATENTS. All contributing project authors may |
9 ## be found in the AUTHORS file in the root of the source tree. | 9 ## be found in the AUTHORS file in the root of the source tree. |
10 ## | 10 ## |
11 ## This file tests vpxenc using hantro_collage_w352h288.yuv as input. To add | 11 ## This file tests vpxenc using hantro_collage_w352h288.yuv as input. To add |
12 ## new tests to this file, do the following: | 12 ## new tests to this file, do the following: |
13 ## 1. Write a shell function (this is your test). | 13 ## 1. Write a shell function (this is your test). |
14 ## 2. Add the function to vpxenc_tests (on a new line). | 14 ## 2. Add the function to vpxenc_tests (on a new line). |
15 ## | 15 ## |
16 . $(dirname $0)/tools_common.sh | 16 . $(dirname $0)/tools_common.sh |
17 | 17 |
18 TEST_FRAMES=10 | 18 readonly TEST_FRAMES=10 |
19 | 19 |
20 # Environment check: Make sure input is available. | 20 # Environment check: Make sure input is available. |
21 vpxenc_verify_environment() { | 21 vpxenc_verify_environment() { |
22 if [ ! -e "${YUV_RAW_INPUT}" ]; then | 22 if [ ! -e "${YUV_RAW_INPUT}" ]; then |
23 echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH." | 23 echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH." |
24 return 1 | 24 return 1 |
25 fi | 25 fi |
| 26 if [ -z "$(vpx_tool_path vpxenc)" ]; then |
| 27 elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent." |
| 28 return 1 |
| 29 fi |
26 } | 30 } |
27 | 31 |
28 vpxenc_can_encode_vp8() { | 32 vpxenc_can_encode_vp8() { |
29 if [ "$(vpxenc_available)" = "yes" ] && \ | 33 if [ "$(vp8_encode_available)" = "yes" ]; then |
30 [ "$(vp8_encode_available)" = "yes" ]; then | |
31 echo yes | 34 echo yes |
32 fi | 35 fi |
33 } | 36 } |
34 | 37 |
35 vpxenc_can_encode_vp9() { | 38 vpxenc_can_encode_vp9() { |
36 if [ "$(vpxenc_available)" = "yes" ] && \ | 39 if [ "$(vp9_encode_available)" = "yes" ]; then |
37 [ "$(vp9_encode_available)" = "yes" ]; then | |
38 echo yes | 40 echo yes |
39 fi | 41 fi |
40 } | 42 } |
41 | 43 |
| 44 # Wrapper function for running vpxenc with pipe input. Requires that |
| 45 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the |
| 46 # input file path and shifted away. All remaining parameters are passed through |
| 47 # to vpxenc. |
| 48 vpxenc_pipe() { |
| 49 local readonly encoder="$(vpx_tool_path vpxenc)" |
| 50 local readonly input="$1" |
| 51 shift |
| 52 cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - "$@" ${devnull} |
| 53 } |
| 54 |
| 55 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to |
| 56 # the directory containing vpxenc. $1 one is used as the input file path and |
| 57 # shifted away. All remaining parameters are passed through to vpxenc. |
| 58 vpxenc() { |
| 59 local readonly encoder="$(vpx_tool_path vpxenc)" |
| 60 local readonly input="${1}" |
| 61 shift |
| 62 eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" "$@" ${devnull} |
| 63 } |
| 64 |
42 vpxenc_vp8_ivf() { | 65 vpxenc_vp8_ivf() { |
43 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then | 66 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then |
44 vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 67 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf" |
45 "${YUV_RAW_INPUT}" vp8.ivf | 68 vpxenc --codec=vp8 \ |
| 69 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 70 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 71 --limit="${TEST_FRAMES}" \ |
| 72 --ivf \ |
| 73 --output="${output}" \ |
| 74 "${YUV_RAW_INPUT}" |
| 75 |
| 76 if [ ! -e "${output}" ]; then |
| 77 elog "Output file does not exist." |
| 78 return 1 |
| 79 fi |
46 fi | 80 fi |
47 } | 81 } |
48 | 82 |
49 vpxenc_vp8_ivf_pipe_input() { | 83 vpxenc_vp8_ivf_piped_input() { |
50 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then | 84 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then |
51 vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 85 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf" |
52 "${YUV_RAW_INPUT}" vp8.ivf - | 86 cat "${YUV_RAW_INPUT}" \ |
| 87 | vpxenc --codec=vp8 \ |
| 88 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 89 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 90 --limit="${TEST_FRAMES}" \ |
| 91 --ivf \ |
| 92 --output="${output}" \ |
| 93 - |
| 94 |
| 95 if [ ! -e "${output}" ]; then |
| 96 elog "Output file does not exist." |
| 97 return 1 |
| 98 fi |
53 fi | 99 fi |
54 } | 100 } |
55 | 101 |
56 vpxenc_vp8_webm() { | 102 vpxenc_vp8_webm() { |
57 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && | 103 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \ |
58 [ "$(webm_io_available)" = "yes" ] ; then | 104 [ "$(webm_io_available)" = "yes" ]; then |
59 vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 105 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm" |
60 "${YUV_RAW_INPUT}" vp8.webm | 106 vpxenc --codec=vp8 \ |
| 107 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 108 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 109 --limit="${TEST_FRAMES}" \ |
| 110 --output="${output}" \ |
| 111 "${YUV_RAW_INPUT}" |
| 112 |
| 113 if [ ! -e "${output}" ]; then |
| 114 elog "Output file does not exist." |
| 115 return 1 |
| 116 fi |
61 fi | 117 fi |
62 } | 118 } |
63 | 119 |
64 vpxenc_vp9_ivf() { | 120 vpxenc_vp9_ivf() { |
65 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then | 121 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then |
66 vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 122 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf" |
67 "${YUV_RAW_INPUT}" vp9.ivf | 123 vpxenc --codec=vp9 \ |
| 124 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 125 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 126 --limit="${TEST_FRAMES}" \ |
| 127 --ivf \ |
| 128 --test-decode=fatal \ |
| 129 --output="${output}" \ |
| 130 "${YUV_RAW_INPUT}" |
| 131 |
| 132 if [ ! -e "${output}" ]; then |
| 133 elog "Output file does not exist." |
| 134 return 1 |
| 135 fi |
68 fi | 136 fi |
69 } | 137 } |
70 | 138 |
71 vpxenc_vp9_webm() { | 139 vpxenc_vp9_webm() { |
72 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && | 140 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \ |
73 [ "$(webm_io_available)" = "yes" ] ; then | 141 [ "$(webm_io_available)" = "yes" ]; then |
74 vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 142 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm" |
75 "${YUV_RAW_INPUT}" vp9.webm | 143 vpxenc --codec=vp9 \ |
| 144 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 145 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 146 --limit="${TEST_FRAMES}" \ |
| 147 --test-decode=fatal \ |
| 148 --output="${output}" \ |
| 149 "${YUV_RAW_INPUT}" |
| 150 |
| 151 if [ ! -e "${output}" ]; then |
| 152 elog "Output file does not exist." |
| 153 return 1 |
| 154 fi |
76 fi | 155 fi |
77 } | 156 } |
78 | 157 |
79 DISABLED_vpxenc_vp9_ivf_lossless() { | 158 vpxenc_vp9_ivf_lossless() { |
80 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then | 159 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then |
81 vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \ | 160 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf" |
82 "${YUV_RAW_INPUT}" vp9_lossless.ivf --lossless | 161 vpxenc --codec=vp9 \ |
| 162 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 163 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 164 --limit="${TEST_FRAMES}" \ |
| 165 --ivf \ |
| 166 --output="${output}" \ |
| 167 --lossless=1 \ |
| 168 --test-decode=fatal \ |
| 169 "${YUV_RAW_INPUT}" |
| 170 |
| 171 if [ ! -e "${output}" ]; then |
| 172 elog "Output file does not exist." |
| 173 return 1 |
| 174 fi |
| 175 fi |
| 176 } |
| 177 |
| 178 vpxenc_vp9_ivf_minq0_maxq0() { |
| 179 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then |
| 180 local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf" |
| 181 vpxenc --codec=vp9 \ |
| 182 --width="${YUV_RAW_INPUT_WIDTH}" \ |
| 183 --height="${YUV_RAW_INPUT_HEIGHT}" \ |
| 184 --limit="${TEST_FRAMES}" \ |
| 185 --ivf \ |
| 186 --output="${output}" \ |
| 187 --min-q=0 \ |
| 188 --max-q=0 \ |
| 189 --test-decode=fatal \ |
| 190 "${YUV_RAW_INPUT}" |
| 191 |
| 192 if [ ! -e "${output}" ]; then |
| 193 elog "Output file does not exist." |
| 194 return 1 |
| 195 fi |
83 fi | 196 fi |
84 } | 197 } |
85 | 198 |
86 vpxenc_tests="vpxenc_vp8_ivf | 199 vpxenc_tests="vpxenc_vp8_ivf |
87 vpxenc_vp8_webm | 200 vpxenc_vp8_webm |
88 vpxenc_vp8_ivf_pipe_input | 201 vpxenc_vp8_ivf_piped_input |
89 vpxenc_vp9_ivf | 202 vpxenc_vp9_ivf |
90 vpxenc_vp9_webm | 203 vpxenc_vp9_webm |
91 DISABLED_vpxenc_vp9_ivf_lossless" | 204 vpxenc_vp9_ivf_lossless |
| 205 vpxenc_vp9_ivf_minq0_maxq0" |
92 | 206 |
93 run_tests vpxenc_verify_environment "${vpxenc_tests}" | 207 run_tests vpxenc_verify_environment "${vpxenc_tests}" |
OLD | NEW |