blob: 0c356638341f812962da319f62f59bc859c06f32 (
plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
#!/usr/bin/env bash
DAV1D="tools/dav1d"
ARGON_DIR='.'
FILMGRAIN=1
CPUMASK=-1
THREADS=0
JOBS=1
usage() {
NAME=$(basename "$0")
{
printf "Usage: %s [-d dav1d] [-a argondir] [-g \$filmgrain] [-c \$cpumask] [-t threads] [-j jobs] [DIRECTORY]...\n" "$NAME"
printf "Example: %s -d /path/to/dav1d -a /path/to/argon/ -g 0 -c avx2 profile0_core\n" "$NAME"
printf "Used to verify that dav1d can decode the Argon AV1 test vectors correctly.\n\n"
printf " DIRECTORY one or more dirs in the argon folder to check against\n"
printf " (default: everything except large scale tiles and stress files)\n"
printf " -d dav1d path to dav1d executable (default: tools/dav1d)\n"
printf " -a dir path to argon dir (default: 'tests/argon' if found; '.' otherwise)\n"
printf " -g \$num enable filmgrain (default: 1)\n"
printf " -c \$mask use restricted cpumask (default: -1)\n"
printf " -t \$num number of threads per dav1d (default: 0)\n"
printf " -j \$num number of parallel dav1d processes (default: 1)\n\n"
} >&2
exit 1
}
error() {
printf "\033[1;91m%s\033[0m\n" "$*" >&2
exit 1
}
fail() {
printf "\033[1K\rMismatch in %s\n" "$1"
(( failed++ ))
}
check_pids() {
new_pids=()
done_pids=()
for p in "${pids[@]}"; do
if kill -0 "$p" 2>/dev/null; then
new_pids+=("$p")
else
done_pids+=("$p")
fi
done
pids=("${new_pids[@]}")
}
wait_pids() {
pid_list=("$@")
for p in "${pid_list[@]}"; do
if ! wait "$p"; then
local file_varname="file$p"
fail "${!file_varname}"
fi
done
}
block_pids() {
while [ ${#pids[@]} -ge "$JOBS" ]; do
check_pids
if [ ${#done_pids} -eq 0 ]; then
sleep 0.2
else
wait_pids "${done_pids[@]}"
fi
done
}
wait_all_pids() {
wait_pids "${pids[@]}"
}
# find tests/argon
tests_dir=$(dirname "$(readlink -f "$0")")
if [ -d "$tests_dir/argon" ]; then
ARGON_DIR="$tests_dir/argon"
fi
while getopts ":d:a:g:c:t:j:" opt; do
case "$opt" in
d)
DAV1D="$OPTARG"
;;
a)
ARGON_DIR="$OPTARG"
;;
g)
FILMGRAIN="$OPTARG"
;;
c)
CPUMASK="$OPTARG"
;;
t)
THREADS="$OPTARG"
;;
j)
JOBS="$OPTARG"
;;
\?)
printf "Error! Invalid option: -%s\n" "$OPTARG" >&2
usage
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -eq 0 ]; then
# Everything except large scale tiles and stress files.
dirs=("$ARGON_DIR/profile0_core" "$ARGON_DIR/profile0_core_special"
"$ARGON_DIR/profile0_not_annexb" "$ARGON_DIR/profile0_not_annexb_special"
"$ARGON_DIR/profile1_core" "$ARGON_DIR/profile1_core_special"
"$ARGON_DIR/profile1_not_annexb" "$ARGON_DIR/profile1_not_annexb_special"
"$ARGON_DIR/profile2_core" "$ARGON_DIR/profile2_core_special"
"$ARGON_DIR/profile2_not_annexb" "$ARGON_DIR/profile2_not_annexb_special"
"$ARGON_DIR/profile_switching")
else
mapfile -t dirs < <(printf "${ARGON_DIR}/%s\n" "$@" | sort -u)
fi
ver_info="dav1d $("$DAV1D" -v 2>&1) filmgrain=$FILMGRAIN cpumask=$CPUMASK" || error "Error! Can't run $DAV1D"
files=()
for d in "${dirs[@]}"; do
if [ -d "$d/streams" ]; then
files+=("${d/%\//}"/streams/*.obu)
fi
done
if [ ${#files[@]} -eq 0 ]; then
error "Error! No files found at ${dirs[*]}"
fi
failed=0
pids=()
for i in "${!files[@]}"; do
f="${files[i]}"
if [ "$FILMGRAIN" -eq 0 ]; then
md5=${f/\/streams\//\/md5_no_film_grain\/}
else
md5=${f/\/streams\//\/md5_ref\/}
fi
md5=$(<"${md5/%obu/md5}") || error "Error! Can't read md5 ${md5} for file ${f}"
md5=${md5/ */}
printf "\033[1K\r[%3d%% %d/%d] Verifying %s" "$(((i+1)*100/${#files[@]}))" "$((i+1))" "${#files[@]}" "$f"
cmd=("$DAV1D" -i "$f" --filmgrain "$FILMGRAIN" --verify "$md5" --cpumask "$CPUMASK" --threads "$THREADS" -q)
if [ "$JOBS" -gt 1 ]; then
"${cmd[@]}" 2>/dev/null &
p=$!
pids+=("$p")
declare "file$p=$f"
block_pids
else
if ! "${cmd[@]}" 2>/dev/null; then
fail "$f"
fi
fi
done
wait_all_pids
if [ "$failed" -ne 0 ]; then
printf "\033[1K\r%d/%d files \033[1;91mfailed\033[0m to verify" "$failed" "${#files[@]}"
else
printf "\033[1K\r%d files \033[1;92msuccessfully\033[0m verified" "${#files[@]}"
fi
printf " in %dm%ds (%s)\n" "$((SECONDS/60))" "$((SECONDS%60))" "$ver_info"
exit $failed
|