mirror of
https://code.videolan.org/videolan/dav1d
synced 2026-06-11 04:03:05 +00:00
Add a -j option to dav1d_argon.bash
This commit is contained in:
committed by
Matthias Dressel
co-authored by
Matthias Dressel
parent
e43904ca48
commit
5c9d651edc
+65
-6
@@ -5,11 +5,12 @@ 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] [DIRECTORY]...\n" "$NAME"
|
||||
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"
|
||||
@@ -18,7 +19,8 @@ usage() {
|
||||
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\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
|
||||
}
|
||||
@@ -28,13 +30,56 @@ error() {
|
||||
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:" opt; do
|
||||
while getopts ":d:a:g:c:t:j:" opt; do
|
||||
case "$opt" in
|
||||
d)
|
||||
DAV1D="$OPTARG"
|
||||
@@ -51,6 +96,9 @@ while getopts ":d:a:g:c:t:" opt; do
|
||||
t)
|
||||
THREADS="$OPTARG"
|
||||
;;
|
||||
j)
|
||||
JOBS="$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
printf "Error! Invalid option: -%s\n" "$OPTARG" >&2
|
||||
usage
|
||||
@@ -89,6 +137,7 @@ if [ ${#files[@]} -eq 0 ]; then
|
||||
fi
|
||||
|
||||
failed=0
|
||||
pids=()
|
||||
for i in "${!files[@]}"; do
|
||||
f="${files[i]}"
|
||||
if [ "$FILMGRAIN" -eq 0 ]; then
|
||||
@@ -100,12 +149,22 @@ for i in "${!files[@]}"; do
|
||||
md5=${md5/ */}
|
||||
|
||||
printf "\033[1K\r[%3d%% %d/%d] Verifying %s" "$(((i+1)*100/${#files[@]}))" "$((i+1))" "${#files[@]}" "$f"
|
||||
if ! "$DAV1D" -i "$f" --filmgrain "$FILMGRAIN" --verify "$md5" --cpumask "$CPUMASK" --threads "$THREADS" -q 2>/dev/null; then
|
||||
printf "\033[1K\rMismatch in %s\n" "$f"
|
||||
(( failed++ ))
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user