2017-06-28 03:21:29 +00:00
|
|
|
#!/bin/sh
|
2017-06-15 12:17:04 +00:00
|
|
|
|
|
|
|
# Helper functions for test scripts.
|
|
|
|
|
2017-06-28 03:21:29 +00:00
|
|
|
set -eu${BASH+o pipefail}
|
2017-06-15 12:17:04 +00:00
|
|
|
|
|
|
|
# Temporary files for encoder input and output.
|
2017-06-28 03:40:54 +00:00
|
|
|
yuvfile="$(mktemp)"
|
|
|
|
hevcfile="$(mktemp)"
|
2017-06-15 12:17:04 +00:00
|
|
|
|
|
|
|
cleanup() {
|
2017-06-28 03:40:54 +00:00
|
|
|
rm -rf "${yuvfile}" "${hevcfile}"
|
2017-06-15 12:17:04 +00:00
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
print_and_run() {
|
|
|
|
printf '\n\n$ %s\n' "$*"
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare() {
|
|
|
|
cleanup
|
|
|
|
print_and_run \
|
|
|
|
ffmpeg -f lavfi -i "mandelbrot=size=${1}" \
|
2017-06-28 03:40:54 +00:00
|
|
|
-vframes "${2}" -pix_fmt yuv420p -f yuv4mpegpipe \
|
2017-06-15 12:17:04 +00:00
|
|
|
"${yuvfile}"
|
|
|
|
}
|
|
|
|
|
|
|
|
valgrind_test() {
|
|
|
|
dimensions="$1"
|
|
|
|
shift
|
|
|
|
frames="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
prepare "${dimensions}" "${frames}"
|
|
|
|
|
|
|
|
print_and_run \
|
|
|
|
libtool execute \
|
|
|
|
valgrind --leak-check=full --error-exitcode=1 -- \
|
|
|
|
../src/kvazaar -i "${yuvfile}" "--input-res=${dimensions}" -o "${hevcfile}" "$@"
|
|
|
|
|
|
|
|
print_and_run \
|
|
|
|
TAppDecoderStatic -b "${hevcfile}"
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
}
|
|
|
|
|
|
|
|
encode_test() {
|
|
|
|
dimensions="$1"
|
|
|
|
shift
|
|
|
|
frames="$1"
|
|
|
|
shift
|
|
|
|
expected_status="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
prepare "${dimensions}" "${frames}"
|
|
|
|
|
|
|
|
set +e
|
|
|
|
print_and_run \
|
|
|
|
libtool execute \
|
|
|
|
../src/kvazaar -i "${yuvfile}" "--input-res=${dimensions}" -o "${hevcfile}" "$@"
|
|
|
|
actual_status="$?"
|
|
|
|
set -e
|
2017-06-28 03:21:29 +00:00
|
|
|
[ ${actual_status} -eq ${expected_status} ]
|
2017-06-15 12:17:04 +00:00
|
|
|
}
|