Index: source/libvpx/test/tools_common.sh |
=================================================================== |
--- source/libvpx/test/tools_common.sh (revision 290053) |
+++ source/libvpx/test/tools_common.sh (working copy) |
@@ -144,6 +144,24 @@ |
fi |
} |
+# Echoes path to $1 when it's executable and exists in ${LIBVPX_BIN_PATH}, or an |
+# empty string. Caller is responsible for testing the string once the function |
+# returns. |
+vpx_tool_path() { |
+ local readonly tool_name="$1" |
+ local tool_path="${LIBVPX_BIN_PATH}/${tool_name}${VPX_TEST_EXE_SUFFIX}" |
+ if [ ! -x "${tool_path}" ]; then |
+ # Try one directory up: when running via examples.sh the tool could be in |
+ # the parent directory of $LIBVPX_BIN_PATH. |
+ tool_path="${LIBVPX_BIN_PATH}/../${tool_name}${VPX_TEST_EXE_SUFFIX}" |
+ fi |
+ |
+ if [ ! -x "${tool_path}" ]; then |
+ tool_path="" |
+ fi |
+ echo "${tool_path}" |
+} |
+ |
# Echoes yes to stdout when the file named by positional parameter one exists |
# in LIBVPX_BIN_PATH, and is executable. |
vpx_tool_available() { |
@@ -182,97 +200,6 @@ |
[ "$(vpx_config_option_enabled CONFIG_WEBM_IO)" = "yes" ] && echo yes |
} |
-# Echoes yes to stdout when vpxdec exists according to vpx_tool_available(). |
-vpxdec_available() { |
- [ -n $(vpx_tool_available vpxdec) ] && echo yes |
-} |
- |
-# Wrapper function for running vpxdec in noblit mode. Requires that |
-# LIBVPX_BIN_PATH points to the directory containing vpxdec. Positional |
-# parameter one is used as the input file path. Positional parameter two, when |
-# present, is interpreted as a boolean flag that means the input should be sent |
-# to vpxdec via pipe from cat instead of directly. |
-vpxdec() { |
- local input="${1}" |
- local pipe_input=${2} |
- |
- if [ $# -gt 2 ]; then |
- # shift away $1 and $2 so the remaining arguments can be passed to vpxdec |
- # via $@. |
- shift 2 |
- fi |
- |
- local decoder="${LIBVPX_BIN_PATH}/vpxdec${VPX_TEST_EXE_SUFFIX}" |
- |
- if [ -z "${pipe_input}" ]; then |
- eval "${VPX_TEST_PREFIX}" "${decoder}" "$input" --summary --noblit "$@" \ |
- ${devnull} |
- else |
- cat "${input}" \ |
- | eval "${VPX_TEST_PREFIX}" "${decoder}" - --summary --noblit "$@" \ |
- ${devnull} |
- fi |
-} |
- |
-# Echoes yes to stdout when vpxenc exists according to vpx_tool_available(). |
-vpxenc_available() { |
- [ -n $(vpx_tool_available vpxenc) ] && echo yes |
-} |
- |
-# Wrapper function for running vpxenc. Positional parameters are interpreted as |
-# follows: |
-# 1 - codec name |
-# 2 - input width |
-# 3 - input height |
-# 4 - number of frames to encode |
-# 5 - path to input file |
-# 6 - path to output file |
-# Note: The output file path must end in .ivf to output an IVF file. |
-# 7 - extra flags |
-# Note: Extra flags currently supports a special case: when set to "-" |
-# input is piped to vpxenc via cat. |
-vpxenc() { |
- local encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}" |
- local codec="${1}" |
- local width=${2} |
- local height=${3} |
- local frames=${4} |
- local input=${5} |
- local output="${VPX_TEST_OUTPUT_DIR}/${6}" |
- local extra_flags=${7} |
- |
- # Because --ivf must be within the command line to get IVF from vpxenc. |
- if echo "${output}" | egrep -q 'ivf$'; then |
- use_ivf=--ivf |
- else |
- unset use_ivf |
- fi |
- |
- if [ "${extra_flags}" = "-" ]; then |
- pipe_input=yes |
- extra_flags=${8} |
- else |
- unset pipe_input |
- fi |
- |
- if [ -z "${pipe_input}" ]; then |
- eval "${VPX_TEST_PREFIX}" "${encoder}" --codec=${codec} --width=${width} \ |
- --height=${height} --limit=${frames} ${use_ivf} ${extra_flags} \ |
- --output="${output}" "${input}" ${devnull} |
- else |
- cat "${input}" \ |
- | eval "${VPX_TEST_PREFIX}" "${encoder}" --codec=${codec} \ |
- --width=${width} --height=${height} --limit=${frames} ${use_ivf} \ |
- ${extra_flags} --output="${output}" - ${devnull} |
- fi |
- |
- if [ ! -e "${output}" ]; then |
- # Return non-zero exit status: output file doesn't exist, so something |
- # definitely went wrong. |
- return 1 |
- fi |
-} |
- |
# Filters strings from positional parameter one using the filter specified by |
# positional parameter two. Filter behavior depends on the presence of a third |
# positional parameter. When parameter three is present, strings that match the |