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) || return 1
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="-nostdin -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 -fflags +bitexact -f framecrc -
109 ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framemd5 -
121 ffmpeg "$@" -vn -f s16le -
127 ffmpeg -flags +bitexact -fflags +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 -fflags +bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -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 -frames:v 5 $* -f nut md5:
194 filter=${test#filter-pixfmts-}
200 showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
201 scale_exclude_fmts=${outfile}_scale_exclude_fmts
202 scale_in_fmts=${outfile}_scale_in_fmts
203 scale_out_fmts=${outfile}_scale_out_fmts
204 in_fmts=${outfile}_in_fmts
206 # exclude pixel formats which are not supported as input
207 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
208 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
209 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
211 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
212 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
215 for pix_fmt in $pix_fmts; do
217 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
220 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
225 sample=$(target_path $1)
228 decfile1="${outdir}/${test}.out-1"
229 decfile2="${outdir}/${test}.out-2"
230 decfile3="${outdir}/${test}.out-3"
231 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
234 ffmpeg $extra_args -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile1
236 # test decoded (and cut) data
237 ffmpeg $extra_args -i "$sample" -flags +bitexact -fflags +bitexact -f wav md5:
238 # the same as above again, with seeking to the start
239 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile2
241 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -f wav md5:
242 # test packet data, with seeking to a specific position
243 ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile3
249 # Disable globbing: command arguments may contain globbing characters and
250 # must be kept verbatim
254 eval $command >"$outfile" 2>$errfile
257 if [ $err -gt 128 ]; then
258 sig=$(kill -l $err 2>/dev/null)
259 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
262 if test -e "$ref" || test $cmp = "oneline" ; then
264 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
265 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
266 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
267 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
268 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
269 null) cat "$outfile" >$cmpfile ;;
272 test $err = 0 && err=$cmperr
273 test $err = 0 || cat $cmpfile
275 echo "reference file '$ref' not found"
279 if [ $err -eq 0 ]; then
282 cmpo="$($base64 <$cmpfile)"
283 erro="$($base64 <$errfile)"
285 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
287 if test $err != 0 && test $gen != "no" ; then
289 cp -f "$outfile" "$ref"
293 if test $err = 0; then
294 rm -f $outfile $errfile $cmpfile $cleanfiles
295 elif test $gen = "no"; then
296 echo "Test $test failed. Look at $errfile for details."
297 test "${V:-0}" -gt 0 && cat $errfile
299 echo "Updating reference failed, possibly no output file was generated."