aom_temporal_svc_encoder.sh 9.27 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 the libaom aom_temporal_svc_encoder example. To add new
12 13
##  tests to this file, do the following:
##    1. Write a shell function (this is your test).
Adrian Grange's avatar
Adrian Grange committed
14
##    2. Add the function to aom_tsvc_encoder_tests (on a new line).
15 16 17 18
##
. $(dirname $0)/tools_common.sh

# Environment check: $YUV_RAW_INPUT is required.
Adrian Grange's avatar
Adrian Grange committed
19
aom_tsvc_encoder_verify_environment() {
20
  if [ ! -e "${YUV_RAW_INPUT}" ]; then
Adrian Grange's avatar
Adrian Grange committed
21
    echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
22 23
    return 1
  fi
Adrian Grange's avatar
Adrian Grange committed
24
  if [ "$(aom_config_option_enabled CONFIG_TEMPORAL_DENOISING)" != "yes" ]; then
25 26 27
    elog "Warning: Temporal denoising is disabled! Spatial denoising will be " \
      "used instead, which is probably not what you want for this test."
  fi
28 29
}

Adrian Grange's avatar
Adrian Grange committed
30
# Runs aom_temporal_svc_encoder using the codec specified by $1 and output file
31
# name by $2. Additional positional parameters are passed directly to
Adrian Grange's avatar
Adrian Grange committed
32 33 34
# aom_temporal_svc_encoder.
aom_tsvc_encoder() {
  local encoder="${LIBAOM_BIN_PATH}/aom_temporal_svc_encoder"
Adrian Grange's avatar
Adrian Grange committed
35
  encoder="${encoder}${AOM_TEST_EXE_SUFFIX}"
36 37
  local codec="$1"
  local output_file_base="$2"
Adrian Grange's avatar
Adrian Grange committed
38
  local output_file="${AOM_TEST_OUTPUT_DIR}/${output_file_base}"
39 40 41 42 43 44 45
  local timebase_num="1"
  local timebase_den="1000"
  local speed="6"
  local frame_drop_thresh="30"

  shift 2

46 47 48 49
  if [ ! -x "${encoder}" ]; then
    elog "${encoder} does not exist or is not executable."
    return 1
  fi
50

Adrian Grange's avatar
Adrian Grange committed
51
  eval "${AOM_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" "${output_file}" \
52
      "${codec}" "${YUV_RAW_INPUT_WIDTH}" "${YUV_RAW_INPUT_HEIGHT}" \
53 54 55 56 57 58
      "${timebase_num}" "${timebase_den}" "${speed}" "${frame_drop_thresh}" \
      "$@" \
      ${devnull}
}

# Confirms that all expected output files exist given the output file name
Adrian Grange's avatar
Adrian Grange committed
59 60
# passed to aom_temporal_svc_encoder.
# The file name passed to aom_temporal_svc_encoder is joined with the stream
61 62 63
# number and the extension .ivf to produce per stream output files.  Here $1 is
# file name, and $2 is expected number of files.
files_exist() {
Adrian Grange's avatar
Adrian Grange committed
64
  local file_name="${AOM_TEST_OUTPUT_DIR}/$1"
65 66 67 68 69 70
  local num_files="$(($2 - 1))"
  for stream_num in $(seq 0 ${num_files}); do
    [ -e "${file_name}_${stream_num}.ivf" ] || return 1
  done
}

71
# Run aom_temporal_svc_encoder in all supported modes for aom and vp9.
72

73 74 75
aom_tsvc_encoder_aom_mode_0() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 0 200 || return 1
76 77 78 79 80
    # Mode 0 produces 1 stream
    files_exist "${FUNCNAME}" 1 || return 1
  fi
}

81 82 83
aom_tsvc_encoder_aom_mode_1() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 1 200 400 || return 1
84 85 86 87 88
    # Mode 1 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

89 90 91
aom_tsvc_encoder_aom_mode_2() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 2 200 400 || return 1
92 93 94 95 96
    # Mode 2 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

97 98 99
aom_tsvc_encoder_aom_mode_3() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 3 200 400 600 || return 1
100 101 102 103 104
    # Mode 3 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

105 106 107
aom_tsvc_encoder_aom_mode_4() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 4 200 400 600 || return 1
108 109 110 111 112
    # Mode 4 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

113 114 115
aom_tsvc_encoder_aom_mode_5() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 5 200 400 600 || return 1
116 117 118 119 120
    # Mode 5 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

121 122 123
aom_tsvc_encoder_aom_mode_6() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 6 200 400 600 || return 1
124 125 126 127 128
    # Mode 6 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

129 130 131
aom_tsvc_encoder_aom_mode_7() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 7 200 400 600 800 1000 || return 1
132 133 134 135 136
    # Mode 7 produces 5 streams
    files_exist "${FUNCNAME}" 5 || return 1
  fi
}

137 138 139
aom_tsvc_encoder_aom_mode_8() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 8 200 400 || return 1
140 141 142 143 144
    # Mode 8 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

145 146 147
aom_tsvc_encoder_aom_mode_9() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 9 200 400 600 || return 1
148 149 150 151 152
    # Mode 9 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

153 154 155
aom_tsvc_encoder_aom_mode_10() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 10 200 400 600 || return 1
156 157 158 159 160
    # Mode 10 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

161 162 163
aom_tsvc_encoder_aom_mode_11() {
  if [ "$(aom_encode_available)" = "yes" ]; then
    aom_tsvc_encoder aom "${FUNCNAME}" 11 200 400 600 || return 1
164 165 166 167 168
    # Mode 11 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
169
aom_tsvc_encoder_vp9_mode_0() {
170
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
171
    aom_tsvc_encoder vp9 "${FUNCNAME}" 0 200 || return 1
172 173 174 175 176
    # Mode 0 produces 1 stream
    files_exist "${FUNCNAME}" 1 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
177
aom_tsvc_encoder_vp9_mode_1() {
178
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
179
    aom_tsvc_encoder vp9 "${FUNCNAME}" 1 200 400 || return 1
180 181 182 183 184
    # Mode 1 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
185
aom_tsvc_encoder_vp9_mode_2() {
186
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
187
    aom_tsvc_encoder vp9 "${FUNCNAME}" 2 200 400 || return 1
188 189 190 191 192
    # Mode 2 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
193
aom_tsvc_encoder_vp9_mode_3() {
194
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
195
    aom_tsvc_encoder vp9 "${FUNCNAME}" 3 200 400 600 || return 1
196 197 198 199 200
    # Mode 3 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
201
aom_tsvc_encoder_vp9_mode_4() {
202
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
203
    aom_tsvc_encoder vp9 "${FUNCNAME}" 4 200 400 600 || return 1
204 205 206 207 208
    # Mode 4 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
209
aom_tsvc_encoder_vp9_mode_5() {
210
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
211
    aom_tsvc_encoder vp9 "${FUNCNAME}" 5 200 400 600 || return 1
212 213 214 215 216
    # Mode 5 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
217
aom_tsvc_encoder_vp9_mode_6() {
218
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
219
    aom_tsvc_encoder vp9 "${FUNCNAME}" 6 200 400 600 || return 1
220 221 222 223 224
    # Mode 6 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
225
aom_tsvc_encoder_vp9_mode_7() {
226
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
227
    aom_tsvc_encoder vp9 "${FUNCNAME}" 7 200 400 600 800 1000 || return 1
228 229 230 231 232
    # Mode 7 produces 5 streams
    files_exist "${FUNCNAME}" 5 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
233
aom_tsvc_encoder_vp9_mode_8() {
234
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
235
    aom_tsvc_encoder vp9 "${FUNCNAME}" 8 200 400 || return 1
236 237 238 239 240
    # Mode 8 produces 2 streams
    files_exist "${FUNCNAME}" 2 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
241
aom_tsvc_encoder_vp9_mode_9() {
242
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
243
    aom_tsvc_encoder vp9 "${FUNCNAME}" 9 200 400 600 || return 1
244 245 246 247 248
    # Mode 9 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
249
aom_tsvc_encoder_vp9_mode_10() {
250
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
251
    aom_tsvc_encoder vp9 "${FUNCNAME}" 10 200 400 600 || return 1
252 253 254 255 256
    # Mode 10 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

Adrian Grange's avatar
Adrian Grange committed
257
aom_tsvc_encoder_vp9_mode_11() {
258
  if [ "$(vp9_encode_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
259
    aom_tsvc_encoder vp9 "${FUNCNAME}" 11 200 400 600 || return 1
260 261 262 263 264
    # Mode 11 produces 3 streams
    files_exist "${FUNCNAME}" 3 || return 1
  fi
}

265 266 267 268 269 270 271 272 273 274 275 276
aom_tsvc_encoder_tests="aom_tsvc_encoder_aom_mode_0
                        aom_tsvc_encoder_aom_mode_1
                        aom_tsvc_encoder_aom_mode_2
                        aom_tsvc_encoder_aom_mode_3
                        aom_tsvc_encoder_aom_mode_4
                        aom_tsvc_encoder_aom_mode_5
                        aom_tsvc_encoder_aom_mode_6
                        aom_tsvc_encoder_aom_mode_7
                        aom_tsvc_encoder_aom_mode_8
                        aom_tsvc_encoder_aom_mode_9
                        aom_tsvc_encoder_aom_mode_10
                        aom_tsvc_encoder_aom_mode_11
Adrian Grange's avatar
Adrian Grange committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290
                        aom_tsvc_encoder_vp9_mode_0
                        aom_tsvc_encoder_vp9_mode_1
                        aom_tsvc_encoder_vp9_mode_2
                        aom_tsvc_encoder_vp9_mode_3
                        aom_tsvc_encoder_vp9_mode_4
                        aom_tsvc_encoder_vp9_mode_5
                        aom_tsvc_encoder_vp9_mode_6
                        aom_tsvc_encoder_vp9_mode_7
                        aom_tsvc_encoder_vp9_mode_8
                        aom_tsvc_encoder_vp9_mode_9
                        aom_tsvc_encoder_vp9_mode_10
                        aom_tsvc_encoder_vp9_mode_11"

run_tests aom_tsvc_encoder_verify_environment "${aom_tsvc_encoder_tests}"