Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / test / vp8_multi_resolution_encoder.sh
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.
19 vp8_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 readonly 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.
35 vp8_mre() {
36   local readonly 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
45 vp8_multi_resolution_encoder_three_formats() {
46   local readonly 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
50   if [ "$(vpx_config_option_enabled CONFIG_MULTI_RES_ENCODING)" = "yes" ]; then
51     if [ "$(vp8_encode_available)" = "yes" ]; then
52       # Param order:
53       #  Input width
54       #  Input height
55       #  Input file path
56       #  Output file names
57       #  Output PSNR
58       vp8_mre "${YUV_RAW_INPUT_WIDTH}" \
59         "${YUV_RAW_INPUT_HEIGHT}" \
60         "${YUV_RAW_INPUT}" \
61         ${output_files} \
62         0
63
64       for output_file in ${output_files}; do
65         if [ ! -e "${output_file}" ]; then
66           elog "Missing output file: ${output_file}"
67           return 1
68         fi
69       done
70     fi
71   fi
72 }
73
74 vp8_mre_tests="vp8_multi_resolution_encoder_three_formats"
75 run_tests vp8_multi_resolution_encoder_verify_environment "${vp8_mre_tests}"