2010-03-15 21:23:24 +02:00
|
|
|
#! /bin/sh
|
|
|
|
|
2010-08-23 20:34:08 +03:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2010-03-15 21:23:24 +02:00
|
|
|
base=$(dirname $0)
|
|
|
|
. "${base}/md5.sh"
|
|
|
|
|
2010-07-27 02:44:06 +03:00
|
|
|
base64=tests/base64
|
|
|
|
|
2010-03-15 21:23:24 +02:00
|
|
|
test="${1#fate-}"
|
2010-07-18 23:19:16 +03:00
|
|
|
samples=$2
|
2010-03-15 21:23:24 +02:00
|
|
|
target_exec=$3
|
2010-07-18 23:19:16 +03:00
|
|
|
target_path=$4
|
2010-03-15 21:23:24 +02:00
|
|
|
command=$5
|
2010-07-09 03:40:45 +03:00
|
|
|
cmp=${6:-diff}
|
|
|
|
ref=${7:-"${base}/ref/fate/${test}"}
|
2012-03-11 02:50:45 +03:00
|
|
|
fuzz=${8:-1}
|
2011-03-22 01:07:54 +02:00
|
|
|
threads=${9:-1}
|
2011-09-04 11:01:59 +03:00
|
|
|
thread_type=${10:-frame+slice}
|
2012-03-05 10:05:56 +03:00
|
|
|
cpuflags=${11:-all}
|
2012-03-11 02:53:19 +03:00
|
|
|
cmp_shift=${12:-0}
|
2012-03-11 03:33:34 +03:00
|
|
|
cmp_target=${13:-0}
|
2012-03-11 03:52:05 +03:00
|
|
|
size_tolerance=${14:-0}
|
2010-07-17 18:02:32 +03:00
|
|
|
|
2010-03-15 21:23:24 +02:00
|
|
|
outdir="tests/data/fate"
|
|
|
|
outfile="${outdir}/${test}"
|
2010-07-21 23:49:34 +03:00
|
|
|
errfile="${outdir}/${test}.err"
|
2010-07-27 02:44:06 +03:00
|
|
|
cmpfile="${outdir}/${test}.diff"
|
|
|
|
repfile="${outdir}/${test}.rep"
|
2010-03-15 21:23:24 +02:00
|
|
|
|
2012-03-11 03:33:34 +03:00
|
|
|
# $1=value1, $2=value2, $3=threshold
|
|
|
|
# prints 0 if absolute difference between value1 and value2 is <= threshold
|
|
|
|
compare(){
|
2012-03-18 20:44:18 +03:00
|
|
|
echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
|
2012-03-11 03:33:34 +03:00
|
|
|
}
|
|
|
|
|
2010-07-17 18:02:34 +03:00
|
|
|
do_tiny_psnr(){
|
2012-03-11 02:53:19 +03:00
|
|
|
psnr=$(tests/tiny_psnr "$1" "$2" 2 $cmp_shift 0)
|
2010-07-17 18:02:34 +03:00
|
|
|
val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
|
2010-07-10 19:58:00 +03:00
|
|
|
size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
|
|
|
|
size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
|
2012-03-11 03:33:34 +03:00
|
|
|
val_cmp=$(compare $val $cmp_target $fuzz)
|
2012-03-11 03:52:05 +03:00
|
|
|
size_cmp=$(compare $size1 $size2 $size_tolerance)
|
|
|
|
if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
|
2010-07-09 03:40:51 +03:00
|
|
|
echo "$psnr"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-07-17 18:02:34 +03:00
|
|
|
oneoff(){
|
2012-03-11 03:33:34 +03:00
|
|
|
do_tiny_psnr "$1" "$2" MAXDIFF
|
2010-07-17 18:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stddev(){
|
2012-03-11 03:33:34 +03:00
|
|
|
do_tiny_psnr "$1" "$2" stddev
|
2010-07-17 18:02:34 +03:00
|
|
|
}
|
|
|
|
|
2010-08-04 09:56:59 +03:00
|
|
|
run(){
|
2010-09-23 12:55:31 +03:00
|
|
|
test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
|
2010-08-04 09:56:59 +03:00
|
|
|
$target_exec $target_path/"$@"
|
|
|
|
}
|
|
|
|
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv(){
|
2012-03-05 10:05:56 +03:00
|
|
|
run avconv -nostats -threads $threads -thread_type $thread_type -cpuflags $cpuflags "$@"
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
framecrc(){
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv "$@" -f framecrc -
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
framemd5(){
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv "$@" -f framemd5 -
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
crc(){
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv "$@" -f crc -
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
md5(){
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv "$@" md5:
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pcm(){
|
2011-07-27 21:56:59 +03:00
|
|
|
avconv "$@" -vn -f s16le -
|
2010-07-18 23:19:30 +03:00
|
|
|
}
|
|
|
|
|
2012-03-11 00:37:41 +03:00
|
|
|
enc_dec_pcm(){
|
|
|
|
out_fmt=$1
|
|
|
|
pcm_fmt=$2
|
|
|
|
shift 2
|
|
|
|
encfile="${outdir}/${test}.${out_fmt}"
|
|
|
|
cleanfiles=$encfile
|
2012-03-17 19:22:47 +03:00
|
|
|
avconv -i $ref "$@" -f $out_fmt -y ${target_path}/${encfile} || return
|
|
|
|
avconv -i ${target_path}/${encfile} -c:a pcm_${pcm_fmt} -f wav -
|
2012-03-11 00:37:41 +03:00
|
|
|
}
|
|
|
|
|
2010-07-20 13:19:28 +03:00
|
|
|
regtest(){
|
|
|
|
t="${test#$2-}"
|
|
|
|
ref=${base}/ref/$2/$t
|
2012-03-05 10:05:56 +03:00
|
|
|
${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags"
|
2010-07-20 13:19:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
codectest(){
|
|
|
|
regtest codec $1 tests/$1
|
|
|
|
}
|
|
|
|
|
|
|
|
lavftest(){
|
|
|
|
regtest lavf lavf tests/vsynth1
|
|
|
|
}
|
|
|
|
|
|
|
|
lavfitest(){
|
2010-07-24 20:13:32 +03:00
|
|
|
cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
|
2010-07-20 13:19:28 +03:00
|
|
|
regtest lavfi lavfi tests/vsynth1
|
|
|
|
}
|
|
|
|
|
|
|
|
seektest(){
|
|
|
|
t="${test#seek-}"
|
|
|
|
ref=${base}/ref/seek/$t
|
|
|
|
case $t in
|
|
|
|
image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
|
|
|
|
*) file=$(echo $t | tr _ '?')
|
|
|
|
for d in acodec vsynth2 lavf; do
|
|
|
|
test -f tests/data/$d/$file && break
|
|
|
|
done
|
|
|
|
file=$(echo tests/data/$d/$file)
|
|
|
|
;;
|
|
|
|
esac
|
2011-09-28 04:13:31 +03:00
|
|
|
run libavformat/seek-test $target_path/$file
|
2010-07-20 13:19:28 +03:00
|
|
|
}
|
2010-07-10 02:55:16 +03:00
|
|
|
|
2010-03-15 21:23:24 +02:00
|
|
|
mkdir -p "$outdir"
|
|
|
|
|
2010-09-23 12:55:31 +03:00
|
|
|
exec 3>&2
|
2010-07-21 23:49:34 +03:00
|
|
|
$command > "$outfile" 2>$errfile
|
2010-07-20 15:54:43 +03:00
|
|
|
err=$?
|
2010-07-09 03:40:45 +03:00
|
|
|
|
2010-07-31 19:53:09 +03:00
|
|
|
if [ $err -gt 128 ]; then
|
|
|
|
sig=$(kill -l $err 2>/dev/null)
|
2010-08-01 15:29:03 +03:00
|
|
|
test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
|
2010-07-31 19:53:09 +03:00
|
|
|
fi
|
|
|
|
|
2010-07-27 02:44:06 +03:00
|
|
|
if test -e "$ref"; then
|
|
|
|
case $cmp in
|
|
|
|
diff) diff -u -w "$ref" "$outfile" >$cmpfile ;;
|
2012-03-11 02:50:45 +03:00
|
|
|
oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
|
|
|
|
stddev) stddev "$ref" "$outfile" >$cmpfile ;;
|
2011-07-04 02:56:38 +03:00
|
|
|
null) cat "$outfile" >$cmpfile ;;
|
2010-07-27 02:44:06 +03:00
|
|
|
esac
|
|
|
|
cmperr=$?
|
|
|
|
test $err = 0 && err=$cmperr
|
|
|
|
test $err = 0 || cat $cmpfile
|
|
|
|
else
|
2010-07-20 13:19:28 +03:00
|
|
|
echo "reference file '$ref' not found"
|
2010-07-27 02:44:06 +03:00
|
|
|
err=1
|
2010-07-20 13:19:28 +03:00
|
|
|
fi
|
|
|
|
|
2010-07-31 19:53:09 +03:00
|
|
|
echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
|
2010-07-10 02:36:04 +03:00
|
|
|
|
2010-07-27 02:44:06 +03:00
|
|
|
test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
|
|
|
|
exit $err
|