3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
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.
11 ## This file tests the libvpx vpx_temporal_svc_encoder example. To add new
12 ## tests to this file, do the following:
13 ## 1. Write a shell function (this is your test).
14 ## 2. Add the function to vpx_tsvc_encoder_tests (on a new line).
16 . $(dirname $0)/tools_common.sh
18 # Environment check: $YUV_RAW_INPUT is required.
19 vpx_tsvc_encoder_verify_environment() {
20 if [ ! -e "${YUV_RAW_INPUT}" ]; then
21 echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
24 if [ "$(vpx_config_option_enabled CONFIG_TEMPORAL_DENOISING)" != "yes" ]; then
25 elog "Warning: Temporal denoising is disabled! Spatial denoising will be " \
26 "used instead, which is probably not what you want for this test."
30 # Runs vpx_temporal_svc_encoder using the codec specified by $1 and output file
31 # name by $2. Additional positional parameters are passed directly to
32 # vpx_temporal_svc_encoder.
34 local encoder="${LIBVPX_BIN_PATH}/vpx_temporal_svc_encoder"
35 encoder="${encoder}${VPX_TEST_EXE_SUFFIX}"
37 local output_file_base="$2"
38 local output_file="${VPX_TEST_OUTPUT_DIR}/${output_file_base}"
39 local timebase_num="1"
40 local timebase_den="1000"
41 local timebase_den_y4m="30"
43 local frame_drop_thresh="30"
45 local error_resilient="1"
49 if [ ! -x "${encoder}" ]; then
50 elog "${encoder} does not exist or is not executable."
54 # TODO(tomfinegan): Verify file output for all thread runs.
55 for threads in $(seq $max_threads); do
56 if [ "$(vpx_config_option_enabled CONFIG_VP9_HIGHBITDEPTH)" != "yes" ]; then
57 eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" \
58 "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
59 "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \
60 "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
61 "$@" ${devnull} || return 1
63 eval "${VPX_TEST_PREFIX}" "${encoder}" "${Y4M_720P_INPUT}" \
64 "${output_file}" "${codec}" "${Y4M_720P_INPUT_WIDTH}" \
65 "${Y4M_720P_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den_y4m}" \
66 "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
67 "$@" ${devnull} || return 1
69 eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" \
70 "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
71 "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \
72 "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
73 "$@" "8" ${devnull} || return 1
78 # Confirms that all expected output files exist given the output file name
79 # passed to vpx_temporal_svc_encoder.
80 # The file name passed to vpx_temporal_svc_encoder is joined with the stream
81 # number and the extension .ivf to produce per stream output files. Here $1 is
82 # file name, and $2 is expected number of files.
84 local file_name="${VPX_TEST_OUTPUT_DIR}/$1"
85 local num_files="$(($2 - 1))"
86 for stream_num in $(seq 0 ${num_files}); do
87 [ -e "${file_name}_${stream_num}.ivf" ] || return 1
91 # Run vpx_temporal_svc_encoder in all supported modes for vp8 and vp9.
93 vpx_tsvc_encoder_vp8_mode_0() {
94 if [ "$(vp8_encode_available)" = "yes" ]; then
95 local output_basename="vpx_tsvc_encoder_vp8_mode_0"
96 vpx_tsvc_encoder vp8 "${output_basename}" 0 200 || return 1
97 # Mode 0 produces 1 stream
98 files_exist "${output_basename}" 1 || return 1
102 vpx_tsvc_encoder_vp8_mode_1() {
103 if [ "$(vp8_encode_available)" = "yes" ]; then
104 local output_basename="vpx_tsvc_encoder_vp8_mode_1"
105 vpx_tsvc_encoder vp8 "${output_basename}" 1 200 400 || return 1
106 # Mode 1 produces 2 streams
107 files_exist "${output_basename}" 2 || return 1
111 vpx_tsvc_encoder_vp8_mode_2() {
112 if [ "$(vp8_encode_available)" = "yes" ]; then
113 local output_basename="vpx_tsvc_encoder_vp8_mode_2"
114 vpx_tsvc_encoder vp8 "${output_basename}" 2 200 400 || return 1
115 # Mode 2 produces 2 streams
116 files_exist "${output_basename}" 2 || return 1
120 vpx_tsvc_encoder_vp8_mode_3() {
121 if [ "$(vp8_encode_available)" = "yes" ]; then
122 local output_basename="vpx_tsvc_encoder_vp8_mode_3"
123 vpx_tsvc_encoder vp8 "${output_basename}" 3 200 400 600 || return 1
124 # Mode 3 produces 3 streams
125 files_exist "${output_basename}" 3 || return 1
129 vpx_tsvc_encoder_vp8_mode_4() {
130 if [ "$(vp8_encode_available)" = "yes" ]; then
131 local output_basename="vpx_tsvc_encoder_vp8_mode_4"
132 vpx_tsvc_encoder vp8 "${output_basename}" 4 200 400 600 || return 1
133 # Mode 4 produces 3 streams
134 files_exist "${output_basename}" 3 || return 1
138 vpx_tsvc_encoder_vp8_mode_5() {
139 if [ "$(vp8_encode_available)" = "yes" ]; then
140 local output_basename="vpx_tsvc_encoder_vp8_mode_5"
141 vpx_tsvc_encoder vp8 "${output_basename}" 5 200 400 600 || return 1
142 # Mode 5 produces 3 streams
143 files_exist "${output_basename}" 3 || return 1
147 vpx_tsvc_encoder_vp8_mode_6() {
148 if [ "$(vp8_encode_available)" = "yes" ]; then
149 local output_basename="vpx_tsvc_encoder_vp8_mode_6"
150 vpx_tsvc_encoder vp8 "${output_basename}" 6 200 400 600 || return 1
151 # Mode 6 produces 3 streams
152 files_exist "${output_basename}" 3 || return 1
156 vpx_tsvc_encoder_vp8_mode_7() {
157 if [ "$(vp8_encode_available)" = "yes" ]; then
158 local output_basename="vpx_tsvc_encoder_vp8_mode_7"
159 vpx_tsvc_encoder vp8 "${output_basename}" 7 200 400 600 800 1000 || return 1
160 # Mode 7 produces 5 streams
161 files_exist "${output_basename}" 5 || return 1
165 vpx_tsvc_encoder_vp8_mode_8() {
166 if [ "$(vp8_encode_available)" = "yes" ]; then
167 local output_basename="vpx_tsvc_encoder_vp8_mode_8"
168 vpx_tsvc_encoder vp8 "${output_basename}" 8 200 400 || return 1
169 # Mode 8 produces 2 streams
170 files_exist "${output_basename}" 2 || return 1
174 vpx_tsvc_encoder_vp8_mode_9() {
175 if [ "$(vp8_encode_available)" = "yes" ]; then
176 local output_basename="vpx_tsvc_encoder_vp8_mode_9"
177 vpx_tsvc_encoder vp8 "${output_basename}" 9 200 400 600 || return 1
178 # Mode 9 produces 3 streams
179 files_exist "${output_basename}" 3 || return 1
183 vpx_tsvc_encoder_vp8_mode_10() {
184 if [ "$(vp8_encode_available)" = "yes" ]; then
185 local output_basename="vpx_tsvc_encoder_vp8_mode_10"
186 vpx_tsvc_encoder vp8 "${output_basename}" 10 200 400 600 || return 1
187 # Mode 10 produces 3 streams
188 files_exist "${output_basename}" 3 || return 1
192 vpx_tsvc_encoder_vp8_mode_11() {
193 if [ "$(vp8_encode_available)" = "yes" ]; then
194 local output_basename="vpx_tsvc_encoder_vp8_mode_11"
195 vpx_tsvc_encoder vp8 "${output_basename}" 11 200 400 600 || return 1
196 # Mode 11 produces 3 streams
197 files_exist "${output_basename}" 3 || return 1
201 vpx_tsvc_encoder_vp9_mode_0() {
202 if [ "$(vp9_encode_available)" = "yes" ]; then
203 local output_basename="vpx_tsvc_encoder_vp9_mode_0"
204 vpx_tsvc_encoder vp9 "${output_basename}" 0 200 || return 1
205 # Mode 0 produces 1 stream
206 files_exist "${output_basename}" 1 || return 1
210 vpx_tsvc_encoder_vp9_mode_1() {
211 if [ "$(vp9_encode_available)" = "yes" ]; then
212 local output_basename="vpx_tsvc_encoder_vp9_mode_1"
213 vpx_tsvc_encoder vp9 "${output_basename}" 1 200 400 || return 1
214 # Mode 1 produces 2 streams
215 files_exist "${output_basename}" 2 || return 1
219 vpx_tsvc_encoder_vp9_mode_2() {
220 if [ "$(vp9_encode_available)" = "yes" ]; then
221 local output_basename="vpx_tsvc_encoder_vp9_mode_2"
222 vpx_tsvc_encoder vp9 "${output_basename}" 2 200 400 || return 1
223 # Mode 2 produces 2 streams
224 files_exist "${output_basename}" 2 || return 1
228 vpx_tsvc_encoder_vp9_mode_3() {
229 if [ "$(vp9_encode_available)" = "yes" ]; then
230 local output_basename="vpx_tsvc_encoder_vp9_mode_3"
231 vpx_tsvc_encoder vp9 "${output_basename}" 3 200 400 600 || return 1
232 # Mode 3 produces 3 streams
233 files_exist "${output_basename}" 3 || return 1
237 vpx_tsvc_encoder_vp9_mode_4() {
238 if [ "$(vp9_encode_available)" = "yes" ]; then
239 local output_basename="vpx_tsvc_encoder_vp9_mode_4"
240 vpx_tsvc_encoder vp9 "${output_basename}" 4 200 400 600 || return 1
241 # Mode 4 produces 3 streams
242 files_exist "${output_basename}" 3 || return 1
246 vpx_tsvc_encoder_vp9_mode_5() {
247 if [ "$(vp9_encode_available)" = "yes" ]; then
248 local output_basename="vpx_tsvc_encoder_vp9_mode_5"
249 vpx_tsvc_encoder vp9 "${output_basename}" 5 200 400 600 || return 1
250 # Mode 5 produces 3 streams
251 files_exist "${output_basename}" 3 || return 1
255 vpx_tsvc_encoder_vp9_mode_6() {
256 if [ "$(vp9_encode_available)" = "yes" ]; then
257 local output_basename="vpx_tsvc_encoder_vp9_mode_6"
258 vpx_tsvc_encoder vp9 "${output_basename}" 6 200 400 600 || return 1
259 # Mode 6 produces 3 streams
260 files_exist "${output_basename}" 3 || return 1
264 vpx_tsvc_encoder_vp9_mode_7() {
265 if [ "$(vp9_encode_available)" = "yes" ]; then
266 local output_basename="vpx_tsvc_encoder_vp9_mode_7"
267 vpx_tsvc_encoder vp9 "${output_basename}" 7 200 400 600 800 1000 || return 1
268 # Mode 7 produces 5 streams
269 files_exist "${output_basename}" 5 || return 1
273 vpx_tsvc_encoder_vp9_mode_8() {
274 if [ "$(vp9_encode_available)" = "yes" ]; then
275 local output_basename="vpx_tsvc_encoder_vp9_mode_8"
276 vpx_tsvc_encoder vp9 "${output_basename}" 8 200 400 || return 1
277 # Mode 8 produces 2 streams
278 files_exist "${output_basename}" 2 || return 1
282 vpx_tsvc_encoder_vp9_mode_9() {
283 if [ "$(vp9_encode_available)" = "yes" ]; then
284 local output_basename="vpx_tsvc_encoder_vp9_mode_9"
285 vpx_tsvc_encoder vp9 "${output_basename}" 9 200 400 600 || return 1
286 # Mode 9 produces 3 streams
287 files_exist "${output_basename}" 3 || return 1
291 vpx_tsvc_encoder_vp9_mode_10() {
292 if [ "$(vp9_encode_available)" = "yes" ]; then
293 local output_basename="vpx_tsvc_encoder_vp9_mode_10"
294 vpx_tsvc_encoder vp9 "${output_basename}" 10 200 400 600 || return 1
295 # Mode 10 produces 3 streams
296 files_exist "${output_basename}" 3 || return 1
300 vpx_tsvc_encoder_vp9_mode_11() {
301 if [ "$(vp9_encode_available)" = "yes" ]; then
302 local output_basename="vpx_tsvc_encoder_vp9_mode_11"
303 vpx_tsvc_encoder vp9 "${output_basename}" 11 200 400 600 || return 1
304 # Mode 11 produces 3 streams
305 files_exist "${output_basename}" 3 || return 1
309 vpx_tsvc_encoder_tests="vpx_tsvc_encoder_vp8_mode_0
310 vpx_tsvc_encoder_vp8_mode_1
311 vpx_tsvc_encoder_vp8_mode_2
312 vpx_tsvc_encoder_vp8_mode_3
313 vpx_tsvc_encoder_vp8_mode_4
314 vpx_tsvc_encoder_vp8_mode_5
315 vpx_tsvc_encoder_vp8_mode_6
316 vpx_tsvc_encoder_vp8_mode_7
317 vpx_tsvc_encoder_vp8_mode_8
318 vpx_tsvc_encoder_vp8_mode_9
319 vpx_tsvc_encoder_vp8_mode_10
320 vpx_tsvc_encoder_vp8_mode_11
321 vpx_tsvc_encoder_vp9_mode_0
322 vpx_tsvc_encoder_vp9_mode_1
323 vpx_tsvc_encoder_vp9_mode_2
324 vpx_tsvc_encoder_vp9_mode_3
325 vpx_tsvc_encoder_vp9_mode_4
326 vpx_tsvc_encoder_vp9_mode_5
327 vpx_tsvc_encoder_vp9_mode_6
328 vpx_tsvc_encoder_vp9_mode_7
329 vpx_tsvc_encoder_vp9_mode_8
330 vpx_tsvc_encoder_vp9_mode_9
331 vpx_tsvc_encoder_vp9_mode_10
332 vpx_tsvc_encoder_vp9_mode_11"
334 run_tests vpx_tsvc_encoder_verify_environment "${vpx_tsvc_encoder_tests}"