3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
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.
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).
16 . $(dirname $0)/tools_common.sh
18 readonly TEST_FRAMES=10
20 # Environment check: Make sure input is available.
21 vpxenc_verify_environment() {
22 if [ ! -e "${YUV_RAW_INPUT}" ]; then
23 elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
26 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
27 if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
28 elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
29 elog "LIBVPX_TEST_DATA_PATH."
33 if [ -z "$(vpx_tool_path vpxenc)" ]; then
34 elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent."
39 vpxenc_can_encode_vp8() {
40 if [ "$(vp8_encode_available)" = "yes" ]; then
45 vpxenc_can_encode_vp9() {
46 if [ "$(vp9_encode_available)" = "yes" ]; then
51 # Echo vpxenc command line parameters allowing use of
52 # hantro_collage_w352h288.yuv as input.
53 yuv_input_hantro_collage() {
54 echo ""${YUV_RAW_INPUT}"
55 --width="${YUV_RAW_INPUT_WIDTH}"
56 --height="${YUV_RAW_INPUT_HEIGHT}""
59 y4m_input_non_square_par() {
60 echo ""${Y4M_NOSQ_PAR_INPUT}""
64 echo ""${Y4M_720P_INPUT}""
67 # Echo default vpxenc real time encoding params. $1 is the codec, which defaults
68 # to vp8 if unspecified.
70 local codec="${1:-vp8}"
71 echo "--codec=${codec}
93 # Forces --passes to 1 with CONFIG_REALTIME_ONLY.
94 vpxenc_passes_param() {
95 if [ "$(vpx_config_option_enabled CONFIG_REALTIME_ONLY)" = "yes" ]; then
102 # Wrapper function for running vpxenc with pipe input. Requires that
103 # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the
104 # input file path and shifted away. All remaining parameters are passed through
107 local encoder="$(vpx_tool_path vpxenc)"
110 cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - \
111 --test-decode=fatal \
115 # Wrapper function for running vpxenc. Requires that LIBVPX_BIN_PATH points to
116 # the directory containing vpxenc. $1 one is used as the input file path and
117 # shifted away. All remaining parameters are passed through to vpxenc.
119 local encoder="$(vpx_tool_path vpxenc)"
122 eval "${VPX_TEST_PREFIX}" "${encoder}" "${input}" \
123 --test-decode=fatal \
128 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
129 local output="${VPX_TEST_OUTPUT_DIR}/vp8.ivf"
130 vpxenc $(yuv_input_hantro_collage) \
132 --limit="${TEST_FRAMES}" \
134 --output="${output}" || return 1
136 if [ ! -e "${output}" ]; then
137 elog "Output file does not exist."
144 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
145 [ "$(webm_io_available)" = "yes" ]; then
146 local output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
147 vpxenc $(yuv_input_hantro_collage) \
149 --limit="${TEST_FRAMES}" \
150 --output="${output}" || return 1
152 if [ ! -e "${output}" ]; then
153 elog "Output file does not exist."
159 vpxenc_vp8_webm_rt() {
160 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
161 [ "$(webm_io_available)" = "yes" ]; then
162 local output="${VPX_TEST_OUTPUT_DIR}/vp8_rt.webm"
163 vpxenc $(yuv_input_hantro_collage) \
164 $(vpxenc_rt_params vp8) \
165 --output="${output}" || return 1
167 if [ ! -e "${output}" ]; then
168 elog "Output file does not exist."
174 vpxenc_vp8_webm_2pass() {
175 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
176 [ "$(webm_io_available)" = "yes" ]; then
177 local output="${VPX_TEST_OUTPUT_DIR}/vp8.webm"
178 vpxenc $(yuv_input_hantro_collage) \
180 --limit="${TEST_FRAMES}" \
181 --output="${output}" \
182 --passes=2 || return 1
184 if [ ! -e "${output}" ]; then
185 elog "Output file does not exist."
191 vpxenc_vp8_webm_lag10_frames20() {
192 if [ "$(vpxenc_can_encode_vp8)" = "yes" ] && \
193 [ "$(webm_io_available)" = "yes" ]; then
194 local lag_total_frames=20
196 local output="${VPX_TEST_OUTPUT_DIR}/vp8_lag10_frames20.webm"
197 vpxenc $(yuv_input_hantro_collage) \
199 --limit="${lag_total_frames}" \
200 --lag-in-frames="${lag_frames}" \
201 --output="${output}" \
203 --passes=2 || return 1
205 if [ ! -e "${output}" ]; then
206 elog "Output file does not exist."
212 vpxenc_vp8_ivf_piped_input() {
213 if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
214 local output="${VPX_TEST_OUTPUT_DIR}/vp8_piped_input.ivf"
215 vpxenc_pipe $(yuv_input_hantro_collage) \
217 --limit="${TEST_FRAMES}" \
219 --output="${output}" || return 1
221 if [ ! -e "${output}" ]; then
222 elog "Output file does not exist."
229 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
230 local output="${VPX_TEST_OUTPUT_DIR}/vp9.ivf"
231 local passes=$(vpxenc_passes_param)
232 vpxenc $(yuv_input_hantro_collage) \
234 --limit="${TEST_FRAMES}" \
237 --output="${output}" || return 1
239 if [ ! -e "${output}" ]; then
240 elog "Output file does not exist."
247 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
248 [ "$(webm_io_available)" = "yes" ]; then
249 local output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
250 local passes=$(vpxenc_passes_param)
251 vpxenc $(yuv_input_hantro_collage) \
253 --limit="${TEST_FRAMES}" \
255 --output="${output}" || return 1
257 if [ ! -e "${output}" ]; then
258 elog "Output file does not exist."
264 vpxenc_vp9_webm_rt() {
265 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
266 [ "$(webm_io_available)" = "yes" ]; then
267 local output="${VPX_TEST_OUTPUT_DIR}/vp9_rt.webm"
268 vpxenc $(yuv_input_hantro_collage) \
269 $(vpxenc_rt_params vp9) \
270 --output="${output}" || return 1
272 if [ ! -e "${output}" ]; then
273 elog "Output file does not exist."
279 vpxenc_vp9_webm_rt_multithread_tiled() {
280 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
281 [ "$(webm_io_available)" = "yes" ]; then
282 local output="${VPX_TEST_OUTPUT_DIR}/vp9_rt_multithread_tiled.webm"
283 local tilethread_min=2
284 local tilethread_max=4
285 local num_threads="$(seq ${tilethread_min} ${tilethread_max})"
286 local num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})"
288 for threads in ${num_threads}; do
289 for tile_cols in ${num_tile_cols}; do
290 vpxenc $(y4m_input_720p) \
291 $(vpxenc_rt_params vp9) \
292 --threads=${threads} \
293 --tile-columns=${tile_cols} \
294 --output="${output}" || return 1
296 if [ ! -e "${output}" ]; then
297 elog "Output file does not exist."
306 vpxenc_vp9_webm_rt_multithread_tiled_frameparallel() {
307 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
308 [ "$(webm_io_available)" = "yes" ]; then
309 local output="${VPX_TEST_OUTPUT_DIR}/vp9_rt_mt_t_fp.webm"
310 local tilethread_min=2
311 local tilethread_max=4
312 local num_threads="$(seq ${tilethread_min} ${tilethread_max})"
313 local num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})"
315 for threads in ${num_threads}; do
316 for tile_cols in ${num_tile_cols}; do
317 vpxenc $(y4m_input_720p) \
318 $(vpxenc_rt_params vp9) \
319 --threads=${threads} \
320 --tile-columns=${tile_cols} \
322 --output="${output}" || return 1
324 if [ ! -e "${output}" ]; then
325 elog "Output file does not exist."
334 vpxenc_vp9_webm_2pass() {
335 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
336 [ "$(webm_io_available)" = "yes" ]; then
337 local output="${VPX_TEST_OUTPUT_DIR}/vp9.webm"
338 vpxenc $(yuv_input_hantro_collage) \
340 --limit="${TEST_FRAMES}" \
341 --output="${output}" \
342 --passes=2 || return 1
344 if [ ! -e "${output}" ]; then
345 elog "Output file does not exist."
351 vpxenc_vp9_ivf_lossless() {
352 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
353 local output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless.ivf"
354 local passes=$(vpxenc_passes_param)
355 vpxenc $(yuv_input_hantro_collage) \
357 --limit="${TEST_FRAMES}" \
359 --output="${output}" \
361 --lossless=1 || return 1
363 if [ ! -e "${output}" ]; then
364 elog "Output file does not exist."
370 vpxenc_vp9_ivf_minq0_maxq0() {
371 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
372 local output="${VPX_TEST_OUTPUT_DIR}/vp9_lossless_minq0_maxq0.ivf"
373 local passes=$(vpxenc_passes_param)
374 vpxenc $(yuv_input_hantro_collage) \
376 --limit="${TEST_FRAMES}" \
378 --output="${output}" \
381 --max-q=0 || return 1
383 if [ ! -e "${output}" ]; then
384 elog "Output file does not exist."
390 vpxenc_vp9_webm_lag10_frames20() {
391 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
392 [ "$(webm_io_available)" = "yes" ]; then
393 local lag_total_frames=20
395 local output="${VPX_TEST_OUTPUT_DIR}/vp9_lag10_frames20.webm"
396 local passes=$(vpxenc_passes_param)
397 vpxenc $(yuv_input_hantro_collage) \
399 --limit="${lag_total_frames}" \
400 --lag-in-frames="${lag_frames}" \
401 --output="${output}" \
403 --auto-alt-ref=1 || return 1
405 if [ ! -e "${output}" ]; then
406 elog "Output file does not exist."
412 # TODO(fgalligan): Test that DisplayWidth is different than video width.
413 vpxenc_vp9_webm_non_square_par() {
414 if [ "$(vpxenc_can_encode_vp9)" = "yes" ] && \
415 [ "$(webm_io_available)" = "yes" ]; then
416 local output="${VPX_TEST_OUTPUT_DIR}/vp9_non_square_par.webm"
417 local passes=$(vpxenc_passes_param)
418 vpxenc $(y4m_input_non_square_par) \
420 --limit="${TEST_FRAMES}" \
422 --output="${output}" || return 1
424 if [ ! -e "${output}" ]; then
425 elog "Output file does not exist."
431 vpxenc_vp9_webm_sharpness() {
432 if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
433 local sharpnesses="0 1 2 3 4 5 6 7"
434 local output="${VPX_TEST_OUTPUT_DIR}/vpxenc_vp9_webm_sharpness.ivf"
438 for sharpness in ${sharpnesses}; do
440 vpxenc $(yuv_input_hantro_collage) \
441 --sharpness="${sharpness}" \
447 --output="${output}" \
448 "${passes}" || return 1
450 if [ ! -e "${output}" ]; then
451 elog "Output file does not exist."
455 this_size=$(stat -c '%s' "${output}")
456 if [ "${this_size}" -lt "${last_size}" ]; then
457 elog "Higher sharpness value yielded lower file size."
458 echo "${this_size}" " < " "${last_size}"
461 last_size="${this_size}"
467 vpxenc_tests="vpxenc_vp8_ivf
470 vpxenc_vp8_ivf_piped_input
474 vpxenc_vp9_webm_rt_multithread_tiled
475 vpxenc_vp9_webm_rt_multithread_tiled_frameparallel
476 vpxenc_vp9_ivf_lossless
477 vpxenc_vp9_ivf_minq0_maxq0
478 vpxenc_vp9_webm_lag10_frames20
479 vpxenc_vp9_webm_non_square_par
480 vpxenc_vp9_webm_sharpness"
482 if [ "$(vpx_config_option_enabled CONFIG_REALTIME_ONLY)" != "yes" ]; then
483 vpxenc_tests="$vpxenc_tests
484 vpxenc_vp8_webm_2pass
485 vpxenc_vp8_webm_lag10_frames20
486 vpxenc_vp9_webm_2pass"
489 run_tests vpxenc_verify_environment "${vpxenc_tests}"