mirrored from https://chromium.googlesource.com/webm/libwebp-test-data
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_lossless.sh
More file actions
executable file
·82 lines (72 loc) · 2.03 KB
/
test_lossless.sh
File metadata and controls
executable file
·82 lines (72 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
##
## test_lossless.sh
##
## Simple test to validate decoding of lossless test vectors using
## the dwebp example utility.
##
## This file distributed under the same terms as libwebp. See the libwebp
## COPYING file for more information.
##
set -e
self=$0
usage() {
cat <<EOT
Usage: $self [options]
Options:
--exec=/path/to/dwebp
--extra_args=<dwebp args>
--formats=format_list (default: $formats)
EOT
exit 1
}
# Decode $1 as a pam and compare to $2. Additional parameters are passed to the
# executable.
check() {
local infile="$1"
local reffile="$2"
local outfile="$infile.${reffile##*.}"
shift 2
printf "${outfile##*/}: "
eval ${executable} "$infile" $extra_args -o "$outfile" "$@" ${devnull}
cmp "$outfile" "$reffile"
echo "OK"
rm -f "$outfile"
}
# PPM (RGB), PAM (RGBA), PGM (YUV), BMP (BGRA/BGR), TIFF (rgbA/RGB)
formats="ppm pam pgm bmp tiff"
devnull="> /dev/null 2>&1"
for opt; do
optval=${opt#*=}
case ${opt} in
--exec=*) executable="${optval}";;
--extra_args=*) extra_args="${optval}";;
--formats=*) formats="${optval}";;
-v) devnull="";;
*) usage;;
esac
done
test_file_dir=$(dirname $self)
executable=${executable:-dwebp}
${executable} 2>/dev/null | grep -q Usage || usage
vectors="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
for i in $vectors; do
for fmt in $formats; do
file="$test_file_dir/lossless_vec_1_$i.webp"
check "$file" "$test_file_dir/grid.$fmt" -$fmt
check "$file" "$test_file_dir/grid.$fmt" -$fmt -noasm
done
done
for i in $vectors; do
for fmt in $formats; do
file="$test_file_dir/lossless_vec_2_$i.webp"
check "$file" "$test_file_dir/peak.$fmt" -$fmt
check "$file" "$test_file_dir/peak.$fmt" -$fmt -noasm
done
done
for fmt in $formats; do
file="$test_file_dir/lossless_color_transform.webp"
check "$file" "$test_file_dir/lossless_color_transform.$fmt" -$fmt
check "$file" "$test_file_dir/lossless_color_transform.$fmt" -$fmt -noasm
done
echo "ALL TESTS OK"