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 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). 15## 16. $(dirname $0)/tools_common.sh 17 18# Environment check: $YUV_RAW_INPUT is required. 19vpx_tsvc_encoder_verify_environment() { 20 if [ ! -e "${YUV_RAW_INPUT}" ]; then 21 echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." 22 return 1 23 fi 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." 27 fi 28} 29 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. 33vpx_tsvc_encoder() { 34 local encoder="${LIBVPX_BIN_PATH}/vpx_temporal_svc_encoder" 35 encoder="${encoder}${VPX_TEST_EXE_SUFFIX}" 36 local codec="$1" 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 speed="6" 42 local frame_drop_thresh="30" 43 44 shift 2 45 46 if [ ! -x "${encoder}" ]; then 47 elog "${encoder} does not exist or is not executable." 48 return 1 49 fi 50 51 eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" "${output_file}" \ 52 "${codec}" "${YUV_RAW_INPUT_WIDTH}" "${YUV_RAW_INPUT_HEIGHT}" \ 53 "${timebase_num}" "${timebase_den}" "${speed}" "${frame_drop_thresh}" \ 54 "$@" \ 55 ${devnull} 56} 57 58# Confirms that all expected output files exist given the output file name 59# passed to vpx_temporal_svc_encoder. 60# The file name passed to vpx_temporal_svc_encoder is joined with the stream 61# number and the extension .ivf to produce per stream output files. Here $1 is 62# file name, and $2 is expected number of files. 63files_exist() { 64 local file_name="${VPX_TEST_OUTPUT_DIR}/$1" 65 local num_files="$(($2 - 1))" 66 for stream_num in $(seq 0 ${num_files}); do 67 [ -e "${file_name}_${stream_num}.ivf" ] || return 1 68 done 69} 70 71# Run vpx_temporal_svc_encoder in all supported modes for vp8 and vp9. 72 73vpx_tsvc_encoder_vp8_mode_0() { 74 if [ "$(vp8_encode_available)" = "yes" ]; then 75 vpx_tsvc_encoder vp8 "${FUNCNAME}" 0 200 || return 1 76 # Mode 0 produces 1 stream 77 files_exist "${FUNCNAME}" 1 || return 1 78 fi 79} 80 81vpx_tsvc_encoder_vp8_mode_1() { 82 if [ "$(vp8_encode_available)" = "yes" ]; then 83 vpx_tsvc_encoder vp8 "${FUNCNAME}" 1 200 400 || return 1 84 # Mode 1 produces 2 streams 85 files_exist "${FUNCNAME}" 2 || return 1 86 fi 87} 88 89vpx_tsvc_encoder_vp8_mode_2() { 90 if [ "$(vp8_encode_available)" = "yes" ]; then 91 vpx_tsvc_encoder vp8 "${FUNCNAME}" 2 200 400 || return 1 92 # Mode 2 produces 2 streams 93 files_exist "${FUNCNAME}" 2 || return 1 94 fi 95} 96 97vpx_tsvc_encoder_vp8_mode_3() { 98 if [ "$(vp8_encode_available)" = "yes" ]; then 99 vpx_tsvc_encoder vp8 "${FUNCNAME}" 3 200 400 600 || return 1 100 # Mode 3 produces 3 streams 101 files_exist "${FUNCNAME}" 3 || return 1 102 fi 103} 104 105vpx_tsvc_encoder_vp8_mode_4() { 106 if [ "$(vp8_encode_available)" = "yes" ]; then 107 vpx_tsvc_encoder vp8 "${FUNCNAME}" 4 200 400 600 || return 1 108 # Mode 4 produces 3 streams 109 files_exist "${FUNCNAME}" 3 || return 1 110 fi 111} 112 113vpx_tsvc_encoder_vp8_mode_5() { 114 if [ "$(vp8_encode_available)" = "yes" ]; then 115 vpx_tsvc_encoder vp8 "${FUNCNAME}" 5 200 400 600 || return 1 116 # Mode 5 produces 3 streams 117 files_exist "${FUNCNAME}" 3 || return 1 118 fi 119} 120 121vpx_tsvc_encoder_vp8_mode_6() { 122 if [ "$(vp8_encode_available)" = "yes" ]; then 123 vpx_tsvc_encoder vp8 "${FUNCNAME}" 6 200 400 600 || return 1 124 # Mode 6 produces 3 streams 125 files_exist "${FUNCNAME}" 3 || return 1 126 fi 127} 128 129vpx_tsvc_encoder_vp8_mode_7() { 130 if [ "$(vp8_encode_available)" = "yes" ]; then 131 vpx_tsvc_encoder vp8 "${FUNCNAME}" 7 200 400 600 800 1000 || return 1 132 # Mode 7 produces 5 streams 133 files_exist "${FUNCNAME}" 5 || return 1 134 fi 135} 136 137vpx_tsvc_encoder_vp8_mode_8() { 138 if [ "$(vp8_encode_available)" = "yes" ]; then 139 vpx_tsvc_encoder vp8 "${FUNCNAME}" 8 200 400 || return 1 140 # Mode 8 produces 2 streams 141 files_exist "${FUNCNAME}" 2 || return 1 142 fi 143} 144 145vpx_tsvc_encoder_vp8_mode_9() { 146 if [ "$(vp8_encode_available)" = "yes" ]; then 147 vpx_tsvc_encoder vp8 "${FUNCNAME}" 9 200 400 600 || return 1 148 # Mode 9 produces 3 streams 149 files_exist "${FUNCNAME}" 3 || return 1 150 fi 151} 152 153vpx_tsvc_encoder_vp8_mode_10() { 154 if [ "$(vp8_encode_available)" = "yes" ]; then 155 vpx_tsvc_encoder vp8 "${FUNCNAME}" 10 200 400 600 || return 1 156 # Mode 10 produces 3 streams 157 files_exist "${FUNCNAME}" 3 || return 1 158 fi 159} 160 161vpx_tsvc_encoder_vp8_mode_11() { 162 if [ "$(vp8_encode_available)" = "yes" ]; then 163 vpx_tsvc_encoder vp8 "${FUNCNAME}" 11 200 400 600 || return 1 164 # Mode 11 produces 3 streams 165 files_exist "${FUNCNAME}" 3 || return 1 166 fi 167} 168 169vpx_tsvc_encoder_vp9_mode_0() { 170 if [ "$(vp9_encode_available)" = "yes" ]; then 171 vpx_tsvc_encoder vp9 "${FUNCNAME}" 0 200 || return 1 172 # Mode 0 produces 1 stream 173 files_exist "${FUNCNAME}" 1 || return 1 174 fi 175} 176 177vpx_tsvc_encoder_vp9_mode_1() { 178 if [ "$(vp9_encode_available)" = "yes" ]; then 179 vpx_tsvc_encoder vp9 "${FUNCNAME}" 1 200 400 || return 1 180 # Mode 1 produces 2 streams 181 files_exist "${FUNCNAME}" 2 || return 1 182 fi 183} 184 185vpx_tsvc_encoder_vp9_mode_2() { 186 if [ "$(vp9_encode_available)" = "yes" ]; then 187 vpx_tsvc_encoder vp9 "${FUNCNAME}" 2 200 400 || return 1 188 # Mode 2 produces 2 streams 189 files_exist "${FUNCNAME}" 2 || return 1 190 fi 191} 192 193vpx_tsvc_encoder_vp9_mode_3() { 194 if [ "$(vp9_encode_available)" = "yes" ]; then 195 vpx_tsvc_encoder vp9 "${FUNCNAME}" 3 200 400 600 || return 1 196 # Mode 3 produces 3 streams 197 files_exist "${FUNCNAME}" 3 || return 1 198 fi 199} 200 201vpx_tsvc_encoder_vp9_mode_4() { 202 if [ "$(vp9_encode_available)" = "yes" ]; then 203 vpx_tsvc_encoder vp9 "${FUNCNAME}" 4 200 400 600 || return 1 204 # Mode 4 produces 3 streams 205 files_exist "${FUNCNAME}" 3 || return 1 206 fi 207} 208 209vpx_tsvc_encoder_vp9_mode_5() { 210 if [ "$(vp9_encode_available)" = "yes" ]; then 211 vpx_tsvc_encoder vp9 "${FUNCNAME}" 5 200 400 600 || return 1 212 # Mode 5 produces 3 streams 213 files_exist "${FUNCNAME}" 3 || return 1 214 fi 215} 216 217vpx_tsvc_encoder_vp9_mode_6() { 218 if [ "$(vp9_encode_available)" = "yes" ]; then 219 vpx_tsvc_encoder vp9 "${FUNCNAME}" 6 200 400 600 || return 1 220 # Mode 6 produces 3 streams 221 files_exist "${FUNCNAME}" 3 || return 1 222 fi 223} 224 225vpx_tsvc_encoder_vp9_mode_7() { 226 if [ "$(vp9_encode_available)" = "yes" ]; then 227 vpx_tsvc_encoder vp9 "${FUNCNAME}" 7 200 400 600 800 1000 || return 1 228 # Mode 7 produces 5 streams 229 files_exist "${FUNCNAME}" 5 || return 1 230 fi 231} 232 233vpx_tsvc_encoder_vp9_mode_8() { 234 if [ "$(vp9_encode_available)" = "yes" ]; then 235 vpx_tsvc_encoder vp9 "${FUNCNAME}" 8 200 400 || return 1 236 # Mode 8 produces 2 streams 237 files_exist "${FUNCNAME}" 2 || return 1 238 fi 239} 240 241vpx_tsvc_encoder_vp9_mode_9() { 242 if [ "$(vp9_encode_available)" = "yes" ]; then 243 vpx_tsvc_encoder vp9 "${FUNCNAME}" 9 200 400 600 || return 1 244 # Mode 9 produces 3 streams 245 files_exist "${FUNCNAME}" 3 || return 1 246 fi 247} 248 249vpx_tsvc_encoder_vp9_mode_10() { 250 if [ "$(vp9_encode_available)" = "yes" ]; then 251 vpx_tsvc_encoder vp9 "${FUNCNAME}" 10 200 400 600 || return 1 252 # Mode 10 produces 3 streams 253 files_exist "${FUNCNAME}" 3 || return 1 254 fi 255} 256 257vpx_tsvc_encoder_vp9_mode_11() { 258 if [ "$(vp9_encode_available)" = "yes" ]; then 259 vpx_tsvc_encoder vp9 "${FUNCNAME}" 11 200 400 600 || return 1 260 # Mode 11 produces 3 streams 261 files_exist "${FUNCNAME}" 3 || return 1 262 fi 263} 264 265vpx_tsvc_encoder_tests="vpx_tsvc_encoder_vp8_mode_0 266 vpx_tsvc_encoder_vp8_mode_1 267 vpx_tsvc_encoder_vp8_mode_2 268 vpx_tsvc_encoder_vp8_mode_3 269 vpx_tsvc_encoder_vp8_mode_4 270 vpx_tsvc_encoder_vp8_mode_5 271 vpx_tsvc_encoder_vp8_mode_6 272 vpx_tsvc_encoder_vp8_mode_7 273 vpx_tsvc_encoder_vp8_mode_8 274 vpx_tsvc_encoder_vp8_mode_9 275 vpx_tsvc_encoder_vp8_mode_10 276 vpx_tsvc_encoder_vp8_mode_11 277 vpx_tsvc_encoder_vp9_mode_0 278 vpx_tsvc_encoder_vp9_mode_1 279 vpx_tsvc_encoder_vp9_mode_2 280 vpx_tsvc_encoder_vp9_mode_3 281 vpx_tsvc_encoder_vp9_mode_4 282 vpx_tsvc_encoder_vp9_mode_5 283 vpx_tsvc_encoder_vp9_mode_6 284 vpx_tsvc_encoder_vp9_mode_7 285 vpx_tsvc_encoder_vp9_mode_8 286 vpx_tsvc_encoder_vp9_mode_9 287 vpx_tsvc_encoder_vp9_mode_10 288 vpx_tsvc_encoder_vp9_mode_11" 289 290run_tests vpx_tsvc_encoder_verify_environment "${vpx_tsvc_encoder_tests}" 291