16 ref=${7:-"${base}/ref/fate/${test}"}
19 thread_type=${10:-frame+slice}
23 size_tolerance=${14:-0}
28 outdir="tests/data/fate"
29 outfile="${outdir}/${test}"
30 errfile="${outdir}/${test}.err"
31 cmpfile="${outdir}/${test}.diff"
32 repfile="${outdir}/${test}.rep"
35 test ${1} = ${1#/} && p=${target_path}/
39 # $1=value1, $2=value2, $3=threshold
40 # prints 0 if absolute difference between value1 and value2 is <= threshold
42 awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
46 psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0)
47 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
48 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
49 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
50 val_cmp=$(compare $val $cmp_target $fuzz)
51 size_cmp=$(compare $size1 $size2 $size_tolerance)
52 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
54 if [ "$val_cmp" != 0 ]; then
55 echo "$3: |$val - $cmp_target| >= $fuzz"
57 if [ "$size_cmp" != 0 ]; then
58 echo "size: |$size1 - $size2| >= $size_tolerance"
65 do_tiny_psnr "$1" "$2" MAXDIFF
69 do_tiny_psnr "$1" "$2" stddev
73 printf '%s\n' "$1" | diff -u -b - "$2"
77 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
78 $target_exec $target_path/"$@"
82 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
83 $target_exec $target_path/"$@" >&3
87 run ffprobe -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
91 run ffprobe -show_frames -v 0 "$@"
95 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
96 ffmpeg_args="-nostats -cpuflags $cpuflags"
98 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
99 ffmpeg_args="${ffmpeg_args} ${arg}"
101 run ffmpeg ${ffmpeg_args}
105 ffmpeg "$@" -flags +bitexact -f framecrc -
109 ffmpeg "$@" -flags +bitexact -f framemd5 -
121 ffmpeg "$@" -vn -f s16le -
127 ffmpeg -flags +bitexact "$@" -f $fmt -
134 src_file=$(target_path $4)
136 encfile="${outdir}/${test}.${out_fmt}"
138 encfile=$(target_path ${encfile})
139 ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
140 ffmpeg -flags +bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
143 FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
144 DEC_OPTS="-threads $threads -idct simple $FLAGS"
145 ENC_OPTS="-threads 1 -idct simple -dct fastint"
154 encfile="${outdir}/${test}.${enc_fmt}"
155 decfile="${outdir}/${test}.out.${dec_fmt}"
156 cleanfiles="$cleanfiles $decfile"
157 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
158 tsrcfile=$(target_path $srcfile)
159 tencfile=$(target_path $encfile)
160 tdecfile=$(target_path $decfile)
161 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
162 -f $enc_fmt -y $tencfile || return
164 echo $(wc -c $encfile)
165 ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
166 -f $dec_fmt -y $tdecfile || return
168 tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
172 t="${test#lavf-fate-}"
173 ref=${base}/ref/lavf-fate/$t
174 ${base}/lavf-regression.sh $t lavf-fate tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
179 ref=${base}/ref/lavf/$t
180 ${base}/lavf-regression.sh $t lavf tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
186 label=${test#filter-}
187 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
188 printf '%-20s' $label
189 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
190 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5:
194 filter=${test#filter-pixfmts-}
199 showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
200 scale_exclude_fmts=${outfile}_scale_exclude_fmts
201 scale_in_fmts=${outfile}_scale_in_fmts
202 scale_out_fmts=${outfile}_scale_out_fmts
203 in_fmts=${outfile}_in_fmts
205 # exclude pixel formats which are not supported as input
206 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
207 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
208 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
210 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
211 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
214 for pix_fmt in $pix_fmts; do
216 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt
219 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
224 sample=$(target_path $1)
227 decfile1="${outdir}/${test}.out-1"
228 decfile2="${outdir}/${test}.out-2"
229 decfile3="${outdir}/${test}.out-3"
230 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
232 # large enough to make ffmpeg.c seek to the start of the file
236 ffmpeg -i "$sample" $extra_args -flags +bitexact -c:a copy -f framecrc -y $decfile1
238 # test decoded (and cut) data
239 ffmpeg -i "$sample" $extra_args -flags +bitexact -f wav md5:
240 # the same as above again, with seeking to the start
241 ffmpeg -ss $start_offset -i "$sample" $extra_args -flags +bitexact -c:a copy -f framecrc -y $decfile2
243 ffmpeg -ss $start_offset -i "$sample" $extra_args -flags +bitexact -f wav md5:
244 # test packet data, with seeking to a specific position
245 ffmpeg -ss 5 -i "$sample" $extra_args -flags +bitexact -c:a copy -f framecrc -y $decfile3
251 # Disable globbing: command arguments may contain globbing characters and
252 # must be kept verbatim
256 eval $command >"$outfile" 2>$errfile
259 if [ $err -gt 128 ]; then
260 sig=$(kill -l $err 2>/dev/null)
261 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
264 if test -e "$ref" || test $cmp = "oneline" ; then
266 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
267 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
268 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
269 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
270 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
271 null) cat "$outfile" >$cmpfile ;;
274 test $err = 0 && err=$cmperr
275 test $err = 0 || cat $cmpfile
277 echo "reference file '$ref' not found"
281 if [ $err -eq 0 ]; then
284 cmpo="$($base64 <$cmpfile)"
285 erro="$($base64 <$errfile)"
287 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
289 if test $err != 0 && test $gen != "no" ; then
291 cp -f "$outfile" "$ref"
295 if test $err = 0; then
296 rm -f $outfile $errfile $cmpfile $cleanfiles
297 elif test $gen = "no"; then
298 echo "Test $test failed. Look at $errfile for details."
299 test "${V:-0}" -gt 0 && cat $errfile
301 echo "Updating reference failed, possibly no output file was generated."