]> granicus.if.org Git - libvpx/blob - test/vpxenc.sh
Merge "vp8: Modify to use closest reference in zero_mv bias."
[libvpx] / test / vpxenc.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 vpxenc using hantro_collage_w352h288.yuv as input. To add
12 ##  new tests to this file, do the following:
13 ##    1. Write a shell function (this is your test).
14 ##    2. Add the function to vpxenc_tests (on a new line).
15 ##
16 . $(dirname $0)/tools_common.sh
17
18 readonly TEST_FRAMES=10
19
20 # Environment check: Make sure input is available.
21 vpxenc_verify_environment() {
22   if [ ! -e "${YUV_RAW_INPUT}" ]; then
23     echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
24     return 1
25   fi
26 }
27
28 vpxenc_can_encode_vp8() {
29   if [ "$(vpxenc_available)" = "yes" ] && \
30      [ "$(vp8_encode_available)" = "yes" ]; then
31     echo yes
32   fi
33 }
34
35 vpxenc_can_encode_vp9() {
36   if [ "$(vpxenc_available)" = "yes" ] && \
37      [ "$(vp9_encode_available)" = "yes" ]; then
38     echo yes
39   fi
40 }
41
42 # Echoes yes to stdout when vpxenc exists according to vpx_tool_available().
43 vpxenc_available() {
44   [ -n "$(vpx_tool_available vpxenc)" ] && echo yes
45 }
46
47 # Wrapper function for running vpxenc with pipe input. Requires that
48 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the
49 # input file path and shifted away. All remaining parameters are passed through
50 # to vpxenc.
51 vpxenc_pipe() {
52   local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}"
53   local readonly input="$1"
54   shift
55   cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - "$@" ${devnull}
56 }
57
58 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
59 # the directory containing vpxenc. $1 one is used as the input file path and
60 # shifted away. All remaining parameters are passed through to vpxenc.
61 vpxenc() {
62   local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}"
63   local readonly input="${1}"
64   shift
65   eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" "$@" ${devnull}
66 }
67
68 vpxenc_vp8_ivf() {
69   if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
70     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
71     vpxenc --codec=vp8 \
72       --width="${YUV_RAW_INPUT_WIDTH}" \
73       --height="${YUV_RAW_INPUT_HEIGHT}" \
74       --limit="${TEST_FRAMES}" \
75       --ivf \
76       --output="${output}" \
77       "${YUV_RAW_INPUT}"
78
79     if [ ! -e "${output}" ]; then
80       elog "Output file does not exist."
81       return 1
82     fi
83   fi
84 }
85
86 vpxenc_vp8_ivf_piped_input() {
87   if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
88     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
89     cat "${YUV_RAW_INPUT}" \
90       | vpxenc --codec=vp8 \
91         --width="${YUV_RAW_INPUT_WIDTH}" \
92         --height="${YUV_RAW_INPUT_HEIGHT}" \
93         --limit="${TEST_FRAMES}" \
94         --ivf \
95         --output="${output}" \
96         -
97
98     if [ ! -e "${output}" ]; then
99       elog "Output file does not exist."
100       return 1
101     fi
102   fi
103 }
104
105 vpxenc_vp8_webm() {
106   if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
107      [ "$(webm_io_available)" = "yes" ]; then
108     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
109     vpxenc --codec=vp8 \
110       --width="${YUV_RAW_INPUT_WIDTH}" \
111       --height="${YUV_RAW_INPUT_HEIGHT}" \
112       --limit="${TEST_FRAMES}" \
113       --output="${output}" \
114       "${YUV_RAW_INPUT}"
115
116     if [ ! -e "${output}" ]; then
117       elog "Output file does not exist."
118       return 1
119     fi
120   fi
121 }
122
123 vpxenc_vp9_ivf() {
124   if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
125     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
126     vpxenc --codec=vp9 \
127       --width="${YUV_RAW_INPUT_WIDTH}" \
128       --height="${YUV_RAW_INPUT_HEIGHT}" \
129       --limit="${TEST_FRAMES}" \
130       --ivf \
131       --test-decode=fatal \
132       --output="${output}" \
133       "${YUV_RAW_INPUT}"
134
135     if [ ! -e "${output}" ]; then
136       elog "Output file does not exist."
137       return 1
138     fi
139   fi
140 }
141
142 vpxenc_vp9_webm() {
143   if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
144      [ "$(webm_io_available)" = "yes" ]; then
145     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
146     vpxenc --codec=vp9 \
147       --width="${YUV_RAW_INPUT_WIDTH}" \
148       --height="${YUV_RAW_INPUT_HEIGHT}" \
149       --limit="${TEST_FRAMES}" \
150       --test-decode=fatal \
151       --output="${output}" \
152       "${YUV_RAW_INPUT}"
153
154     if [ ! -e "${output}" ]; then
155       elog "Output file does not exist."
156       return 1
157     fi
158   fi
159 }
160
161 vpxenc_vp9_ivf_lossless() {
162   if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
163     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
164     vpxenc --codec=vp9 \
165       --width="${YUV_RAW_INPUT_WIDTH}" \
166       --height="${YUV_RAW_INPUT_HEIGHT}" \
167       --limit="${TEST_FRAMES}" \
168       --ivf \
169       --output="${output}" \
170       --lossless=1 \
171       --test-decode=fatal \
172       "${YUV_RAW_INPUT}"
173
174     if [ ! -e "${output}" ]; then
175       elog "Output file does not exist."
176       return 1
177     fi
178   fi
179 }
180
181 vpxenc_vp9_ivf_minq0_maxq0() {
182   if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
183     local readonly output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
184     vpxenc --codec=vp9 \
185       --width="${YUV_RAW_INPUT_WIDTH}" \
186       --height="${YUV_RAW_INPUT_HEIGHT}" \
187       --limit="${TEST_FRAMES}" \
188       --ivf \
189       --output="${output}" \
190       --min-q=0 \
191       --max-q=0 \
192       --test-decode=fatal \
193       "${YUV_RAW_INPUT}"
194
195     if [ ! -e "${output}" ]; then
196       elog "Output file does not exist."
197       return 1
198     fi
199   fi
200 }
201
202 vpxenc_tests="vpxenc_vp8_ivf
203               vpxenc_vp8_webm
204               vpxenc_vp8_ivf_piped_input
205               vpxenc_vp9_ivf
206               vpxenc_vp9_webm
207               vpxenc_vp9_ivf_lossless
208               vpxenc_vp9_ivf_minq0_maxq0"
209
210 run_tests vpxenc_verify_environment "${vpxenc_tests}"