• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 vp8_multi_resolution_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 vp8_mre_tests (on a new line).
15##
16. $(dirname $0)/tools_common.sh
17
18# Environment check: $YUV_RAW_INPUT is required.
19vp8_multi_resolution_encoder_verify_environment() {
20  if [ "$(vpx_config_option_enabled CONFIG_MULTI_RES_ENCODING)" = "yes" ]; then
21    if [ ! -e "${YUV_RAW_INPUT}" ]; then
22      elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
23      return 1
24    fi
25    local app="vp8_multi_resolution_encoder"
26    if [ -z "$(vpx_tool_path "${app}")" ]; then
27      elog "${app} not found. It must exist in LIBVPX_BIN_PATH or its parent."
28      return 1
29    fi
30  fi
31}
32
33# Runs vp8_multi_resolution_encoder. Simply forwards all arguments to
34# vp8_multi_resolution_encoder after building path to the executable.
35vp8_mre() {
36  local encoder="$(vpx_tool_path vp8_multi_resolution_encoder)"
37  if [ ! -x "${encoder}" ]; then
38    elog "${encoder} does not exist or is not executable."
39    return 1
40  fi
41
42  eval "${VPX_TEST_PREFIX}" "${encoder}" "$@" ${devnull}
43}
44
45vp8_multi_resolution_encoder_three_formats() {
46  local output_files="${VPX_TEST_OUTPUT_DIR}/vp8_mre_0.ivf
47                      ${VPX_TEST_OUTPUT_DIR}/vp8_mre_1.ivf
48                      ${VPX_TEST_OUTPUT_DIR}/vp8_mre_2.ivf"
49  local layer_bitrates="150 80 50"
50  local keyframe_insert="200"
51  local temporal_layers="3 3 3"
52  local framerate="30"
53
54  if [ "$(vpx_config_option_enabled CONFIG_MULTI_RES_ENCODING)" = "yes" ]; then
55    if [ "$(vp8_encode_available)" = "yes" ]; then
56      # Param order:
57      #  Input width
58      #  Input height
59      #  Framerate
60      #  Input file path
61      #  Output file names
62      #  Layer bitrates
63      #  Temporal layers
64      #  Keyframe insert
65      #  Output PSNR
66      vp8_mre "${YUV_RAW_INPUT_WIDTH}" \
67        "${YUV_RAW_INPUT_HEIGHT}" \
68        "${framerate}" \
69        "${YUV_RAW_INPUT}" \
70        ${output_files} \
71        ${layer_bitrates} \
72        ${temporal_layers} \
73        "${keyframe_insert}" \
74        0
75
76      for output_file in ${output_files}; do
77        if [ ! -e "${output_file}" ]; then
78          elog "Missing output file: ${output_file}"
79          return 1
80        fi
81      done
82    fi
83  fi
84}
85
86vp8_mre_tests="vp8_multi_resolution_encoder_three_formats"
87run_tests vp8_multi_resolution_encoder_verify_environment "${vp8_mre_tests}"
88