2010-03-15 20:23:24 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
2010-08-23 19:34:08 +02:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2010-03-15 20:23:24 +01:00
|
|
|
base=$(dirname $0)
|
|
|
|
. "${base}/md5.sh"
|
|
|
|
|
2010-07-27 01:44:06 +02:00
|
|
|
base64=tests/base64
|
|
|
|
|
2010-03-15 20:23:24 +01:00
|
|
|
test="${1#fate-}"
|
2010-07-18 22:19:16 +02:00
|
|
|
samples=$2
|
2010-03-15 20:23:24 +01:00
|
|
|
target_exec=$3
|
2010-07-18 22:19:16 +02:00
|
|
|
target_path=$4
|
2010-03-15 20:23:24 +01:00
|
|
|
command=$5
|
2010-07-09 02:40:45 +02:00
|
|
|
cmp=${6:-diff}
|
|
|
|
ref=${7:-"${base}/ref/fate/${test}"}
|
2012-03-11 00:50:45 +01:00
|
|
|
fuzz=${8:-1}
|
2011-03-22 00:07:54 +01:00
|
|
|
threads=${9:-1}
|
2011-09-04 10:01:59 +02:00
|
|
|
thread_type=${10:-frame+slice}
|
2012-03-05 08:05:56 +01:00
|
|
|
cpuflags=${11:-all}
|
2012-03-11 00:53:19 +01:00
|
|
|
cmp_shift=${12:-0}
|
2012-03-11 01:33:34 +01:00
|
|
|
cmp_target=${13:-0}
|
2012-03-11 01:52:05 +01:00
|
|
|
size_tolerance=${14:-0}
|
2012-05-17 20:14:17 +02:00
|
|
|
cmp_unit=${15:-2}
|
2010-07-17 17:02:32 +02:00
|
|
|
|
2010-03-15 20:23:24 +01:00
|
|
|
outdir="tests/data/fate"
|
|
|
|
outfile="${outdir}/${test}"
|
2010-07-21 22:49:34 +02:00
|
|
|
errfile="${outdir}/${test}.err"
|
2010-07-27 01:44:06 +02:00
|
|
|
cmpfile="${outdir}/${test}.diff"
|
|
|
|
repfile="${outdir}/${test}.rep"
|
2010-03-15 20:23:24 +01:00
|
|
|
|
2012-04-17 17:47:57 +02:00
|
|
|
target_path(){
|
|
|
|
test ${1} = ${1#/} && p=${target_path}/
|
|
|
|
echo ${p}${1}
|
|
|
|
}
|
|
|
|
|
2012-03-11 01:33:34 +01:00
|
|
|
# $1=value1, $2=value2, $3=threshold
|
|
|
|
# prints 0 if absolute difference between value1 and value2 is <= threshold
|
|
|
|
compare(){
|
2012-03-18 18:44:18 +01:00
|
|
|
echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
|
2012-03-11 01:33:34 +01:00
|
|
|
}
|
|
|
|
|
2010-07-17 17:02:34 +02:00
|
|
|
do_tiny_psnr(){
|
2012-05-17 20:14:17 +02:00
|
|
|
psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0)
|
2010-07-17 17:02:34 +02:00
|
|
|
val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
|
2010-07-10 18:58:00 +02:00
|
|
|
size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
|
|
|
|
size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
|
2012-03-11 01:33:34 +01:00
|
|
|
val_cmp=$(compare $val $cmp_target $fuzz)
|
2012-03-11 01:52:05 +01:00
|
|
|
size_cmp=$(compare $size1 $size2 $size_tolerance)
|
|
|
|
if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
|
2010-07-09 02:40:51 +02:00
|
|
|
echo "$psnr"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-07-17 17:02:34 +02:00
|
|
|
oneoff(){
|
2012-03-11 01:33:34 +01:00
|
|
|
do_tiny_psnr "$1" "$2" MAXDIFF
|
2010-07-17 17:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stddev(){
|
2012-03-11 01:33:34 +01:00
|
|
|
do_tiny_psnr "$1" "$2" stddev
|
2010-07-17 17:02:34 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 00:43:11 +02:00
|
|
|
oneline(){
|
2012-05-15 12:52:28 +02:00
|
|
|
printf '%s\n' "$1" | diff -u -b - "$2"
|
2012-05-04 00:43:11 +02:00
|
|
|
}
|
|
|
|
|
2010-08-04 08:56:59 +02:00
|
|
|
run(){
|
2010-09-23 11:55:31 +02:00
|
|
|
test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
|
2010-08-04 08:56:59 +02:00
|
|
|
$target_exec $target_path/"$@"
|
|
|
|
}
|
|
|
|
|
2012-05-03 20:01:00 +02:00
|
|
|
probefmt(){
|
2012-11-20 00:21:23 +01:00
|
|
|
run ffprobe -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
|
2012-05-03 20:01:00 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg(){
|
2012-05-29 11:41:55 +02:00
|
|
|
dec_opts="-threads $threads -thread_type $thread_type"
|
2012-07-09 22:10:38 +02:00
|
|
|
ffmpeg_args="-nostats -cpuflags $cpuflags"
|
2012-05-29 11:41:55 +02:00
|
|
|
for arg in $@; do
|
2012-12-05 17:33:12 +01:00
|
|
|
[ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
|
2012-07-09 22:10:38 +02:00
|
|
|
ffmpeg_args="${ffmpeg_args} ${arg}"
|
2012-05-29 11:41:55 +02:00
|
|
|
done
|
2012-07-09 22:10:38 +02:00
|
|
|
run ffmpeg ${ffmpeg_args}
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
framecrc(){
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg "$@" -f framecrc -
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
framemd5(){
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg "$@" -f framemd5 -
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
crc(){
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg "$@" -f crc -
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
md5(){
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg "$@" md5:
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pcm(){
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg "$@" -vn -f s16le -
|
2010-07-18 22:19:30 +02:00
|
|
|
}
|
|
|
|
|
2012-03-10 22:37:41 +01:00
|
|
|
enc_dec_pcm(){
|
|
|
|
out_fmt=$1
|
2012-04-17 17:47:57 +02:00
|
|
|
dec_fmt=$2
|
|
|
|
pcm_fmt=$3
|
|
|
|
src_file=$(target_path $4)
|
|
|
|
shift 4
|
2012-03-10 22:37:41 +01:00
|
|
|
encfile="${outdir}/${test}.${out_fmt}"
|
|
|
|
cleanfiles=$encfile
|
2012-04-17 17:47:57 +02:00
|
|
|
encfile=$(target_path ${encfile})
|
2012-05-27 15:34:47 +02:00
|
|
|
ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
|
2012-06-10 02:57:25 +02:00
|
|
|
ffmpeg -flags +bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
|
2012-03-10 22:37:41 +01:00
|
|
|
}
|
|
|
|
|
2012-05-18 11:33:28 +02:00
|
|
|
FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact"
|
|
|
|
DEC_OPTS="-threads $threads -idct simple $FLAGS"
|
|
|
|
ENC_OPTS="-threads 1 -idct simple -dct fastint"
|
|
|
|
|
|
|
|
enc_dec(){
|
|
|
|
src_fmt=$1
|
|
|
|
srcfile=$2
|
|
|
|
enc_fmt=$3
|
|
|
|
enc_opt=$4
|
|
|
|
dec_fmt=$5
|
|
|
|
dec_opt=$6
|
2013-01-19 21:04:06 +01:00
|
|
|
ddc_opt=$8
|
2012-05-18 11:33:28 +02:00
|
|
|
encfile="${outdir}/${test}.${enc_fmt}"
|
|
|
|
decfile="${outdir}/${test}.out.${dec_fmt}"
|
|
|
|
cleanfiles="$cleanfiles $decfile"
|
|
|
|
test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
|
|
|
|
tsrcfile=$(target_path $srcfile)
|
|
|
|
tencfile=$(target_path $encfile)
|
|
|
|
tdecfile=$(target_path $decfile)
|
2012-05-30 01:39:24 +02:00
|
|
|
ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
|
2012-05-18 11:33:28 +02:00
|
|
|
-f $enc_fmt -y $tencfile || return
|
|
|
|
do_md5sum $encfile
|
|
|
|
echo $(wc -c $encfile)
|
2013-01-21 16:28:04 +01:00
|
|
|
ffmpeg $DEC_OPTS $ddc_opt -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
|
2012-05-18 11:33:28 +02:00
|
|
|
-f $dec_fmt -y $tdecfile || return
|
|
|
|
do_md5sum $decfile
|
|
|
|
tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
|
|
|
|
}
|
|
|
|
|
2010-07-20 12:19:28 +02:00
|
|
|
regtest(){
|
|
|
|
t="${test#$2-}"
|
|
|
|
ref=${base}/ref/$2/$t
|
2012-03-07 02:57:53 +01:00
|
|
|
${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$samples"
|
2010-07-20 12:19:28 +02:00
|
|
|
}
|
|
|
|
|
2012-02-12 11:52:10 +01:00
|
|
|
lavffatetest(){
|
|
|
|
regtest lavf lavf-fate tests/vsynth1
|
|
|
|
}
|
|
|
|
|
2010-07-20 12:19:28 +02:00
|
|
|
lavftest(){
|
|
|
|
regtest lavf lavf tests/vsynth1
|
|
|
|
}
|
|
|
|
|
|
|
|
lavfitest(){
|
2010-07-24 19:13:32 +02:00
|
|
|
cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
|
2010-07-20 12:19:28 +02:00
|
|
|
regtest lavfi lavfi tests/vsynth1
|
|
|
|
}
|
|
|
|
|
2010-03-15 20:23:24 +01:00
|
|
|
mkdir -p "$outdir"
|
|
|
|
|
2013-01-02 23:22:46 +01:00
|
|
|
# Disable globbing: command arguments may contain globbing characters and
|
|
|
|
# must be kept verbatim
|
|
|
|
set -f
|
|
|
|
|
2010-09-23 11:55:31 +02:00
|
|
|
exec 3>&2
|
2012-05-18 11:33:28 +02:00
|
|
|
eval $command >"$outfile" 2>$errfile
|
2010-07-20 14:54:43 +02:00
|
|
|
err=$?
|
2010-07-09 02:40:45 +02:00
|
|
|
|
2010-07-31 18:53:09 +02:00
|
|
|
if [ $err -gt 128 ]; then
|
|
|
|
sig=$(kill -l $err 2>/dev/null)
|
2010-08-01 14:29:03 +02:00
|
|
|
test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
|
2010-07-31 18:53:09 +02:00
|
|
|
fi
|
|
|
|
|
2012-05-04 00:43:11 +02:00
|
|
|
if test -e "$ref" || test $cmp = "oneline" ; then
|
2010-07-27 01:44:06 +02:00
|
|
|
case $cmp in
|
2012-05-14 23:31:08 +02:00
|
|
|
diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
|
2012-03-11 00:50:45 +01:00
|
|
|
oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
|
|
|
|
stddev) stddev "$ref" "$outfile" >$cmpfile ;;
|
2012-05-04 00:43:11 +02:00
|
|
|
oneline)oneline "$ref" "$outfile" >$cmpfile ;;
|
2011-07-04 01:56:38 +02:00
|
|
|
null) cat "$outfile" >$cmpfile ;;
|
2010-07-27 01:44:06 +02:00
|
|
|
esac
|
|
|
|
cmperr=$?
|
|
|
|
test $err = 0 && err=$cmperr
|
|
|
|
test $err = 0 || cat $cmpfile
|
|
|
|
else
|
2010-07-20 12:19:28 +02:00
|
|
|
echo "reference file '$ref' not found"
|
2010-07-27 01:44:06 +02:00
|
|
|
err=1
|
2010-07-20 12:19:28 +02:00
|
|
|
fi
|
|
|
|
|
2010-07-31 18:53:09 +02:00
|
|
|
echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
|
2010-07-10 01:36:04 +02:00
|
|
|
|
2011-12-22 18:17:13 +01:00
|
|
|
if test $err = 0; then
|
|
|
|
rm -f $outfile $errfile $cmpfile $cleanfiles
|
|
|
|
else
|
|
|
|
echo "Test $test failed. Look at $errfile for details."
|
|
|
|
fi
|
2010-07-27 01:44:06 +02:00
|
|
|
exit $err
|