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
18YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
19YUV_RAW_INPUT_WIDTH=352
20YUV_RAW_INPUT_HEIGHT=288
21TEST_FRAMES=10
22
23# Environment check: Make sure input is available.
24vpxenc_verify_environment() {
25  if [ ! -e "${YUV_RAW_INPUT}" ]; then
26    echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
27    return 1
28  fi
29}
30
31vpxenc_can_encode_vp8() {
32  if [ "$(vpxenc_available)" = "yes" ] && \
33     [ "$(vp8_encode_available)" = "yes" ]; then
34    echo yes
35  fi
36}
37
38vpxenc_can_encode_vp9() {
39  if [ "$(vpxenc_available)" = "yes" ] && \
40     [ "$(vp9_encode_available)" = "yes" ]; then
41    echo yes
42  fi
43}
44
45vpxenc_vp8_ivf() {
46  if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
47    vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
48        "${YUV_RAW_INPUT}" vp8.ivf
49  fi
50}
51
52vpxenc_vp8_ivf_pipe_input() {
53  if [ "$(vpxenc_can_encode_vp8)" = "yes" ]; then
54    vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
55        "${YUV_RAW_INPUT}" vp8.ivf -
56  fi
57}
58
59vpxenc_vp8_webm() {
60  if [ "$(vpxenc_can_encode_vp8)" = "yes" ] &&
61     [ "$(webm_io_available)" = "yes" ] ; then
62    vpxenc vp8 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
63        "${YUV_RAW_INPUT}" vp8.webm
64  fi
65}
66
67vpxenc_vp9_ivf() {
68  if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
69    vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
70        "${YUV_RAW_INPUT}" vp9.ivf
71  fi
72}
73
74vpxenc_vp9_webm() {
75  if [ "$(vpxenc_can_encode_vp9)" = "yes" ] &&
76     [ "$(webm_io_available)" = "yes" ] ; then
77    vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
78        "${YUV_RAW_INPUT}" vp9.webm
79  fi
80}
81
82DISABLED_vpxenc_vp9_ivf_lossless() {
83  if [ "$(vpxenc_can_encode_vp9)" = "yes" ]; then
84    vpxenc vp9 ${YUV_RAW_INPUT_WIDTH} ${YUV_RAW_INPUT_HEIGHT} ${TEST_FRAMES} \
85        "${YUV_RAW_INPUT}" vp9_lossless.ivf --lossless
86  fi
87}
88
89vpxenc_tests="vpxenc_vp8_ivf
90              vpxenc_vp8_webm
91              vpxenc_vp8_ivf_pipe_input
92              vpxenc_vp9_ivf
93              vpxenc_vp9_webm
94              DISABLED_vpxenc_vp9_ivf_lossless"
95
96run_tests vpxenc_verify_environment "${vpxenc_tests}"
97