blob: 5e472716da35898da7441da4ccbf114af5e38822 [file] [log] [blame]
Tom Fineganeaa4dff2014-05-05 11:18:37 -07001#!/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 resize_util example code. To add new tests to
12## this file, do the following:
13## 1. Write a shell function (this is your test).
14## 2. Add the function to resize_util_tests (on a new line).
15##
16. $(dirname $0)/tools_common.sh
17
18# Environment check: $YUV_RAW_INPUT is required.
19resize_util_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}
25
26# Resizes $YUV_RAW_INPUT using the resize_util example. $1 is the output
27# dimensions that will be passed to resize_util.
28resize_util() {
29 local resizer="${LIBVPX_BIN_PATH}/resize_util${VPX_TEST_EXE_SUFFIX}"
30 local output_file="${VPX_TEST_OUTPUT_DIR}/resize_util.raw"
31 local frames_to_resize="10"
32 local target_dimensions="$1"
33
34 # resize_util is available only when CONFIG_SHARED is disabled.
35 if [ -z "$(vpx_config_option_enabled CONFIG_SHARED)" ]; then
Tom Finegan12672c22014-06-16 10:57:00 -070036 if [ ! -x "${resizer}" ]; then
37 elog "${resizer} does not exist or is not executable."
38 return 1
39 fi
Tom Fineganeaa4dff2014-05-05 11:18:37 -070040
Tom Finegan926a6f62014-07-10 15:17:05 -070041 eval "${VPX_TEST_PREFIX}" "${resizer}" "${YUV_RAW_INPUT}" \
Tom Fineganeaa4dff2014-05-05 11:18:37 -070042 "${YUV_RAW_INPUT_WIDTH}x${YUV_RAW_INPUT_HEIGHT}" \
43 "${target_dimensions}" "${output_file}" ${frames_to_resize} \
44 ${devnull}
45
46 [ -e "${output_file}" ] || return 1
47 fi
48}
49
50# Halves each dimension of $YUV_RAW_INPUT using resize_util().
51resize_down() {
52 local target_width=$((${YUV_RAW_INPUT_WIDTH} / 2))
53 local target_height=$((${YUV_RAW_INPUT_HEIGHT} / 2))
54
55 resize_util "${target_width}x${target_height}"
56}
57
58# Doubles each dimension of $YUV_RAW_INPUT using resize_util().
59resize_up() {
60 local target_width=$((${YUV_RAW_INPUT_WIDTH} * 2))
61 local target_height=$((${YUV_RAW_INPUT_HEIGHT} * 2))
62
63 resize_util "${target_width}x${target_height}"
64}
65
66resize_util_tests="resize_down
67 resize_up"
68
69run_tests resize_util_verify_environment "${resize_util_tests}"