16 ref=${7:-"${base}/ref/fate/${test}"}
19 thread_type=${10:-frame+slice}
23 size_tolerance=${14:-0}
27 outdir="tests/data/fate"
28 outfile="${outdir}/${test}"
29 errfile="${outdir}/${test}.err"
30 cmpfile="${outdir}/${test}.diff"
31 repfile="${outdir}/${test}.rep"
34 test ${1} = ${1#/} && p=${target_path}/
38 # $1=value1, $2=value2, $3=threshold
39 # prints 0 if absolute difference between value1 and value2 is <= threshold
41 echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
45 psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0)
46 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
47 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
48 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
49 val_cmp=$(compare $val $cmp_target $fuzz)
50 size_cmp=$(compare $size1 $size2 $size_tolerance)
51 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
58 do_tiny_psnr "$1" "$2" MAXDIFF
62 do_tiny_psnr "$1" "$2" stddev
66 printf '%s\n' "$1" | diff -u -b - "$2"
70 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
71 $target_exec $target_path/"$@"
75 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
76 $target_exec $target_path/"$@" >&3
80 run ffprobe -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
84 run ffprobe -show_frames -v 0 "$@"
88 dec_opts="-threads $threads -thread_type $thread_type"
89 ffmpeg_args="-nostats -cpuflags $cpuflags"
91 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
92 ffmpeg_args="${ffmpeg_args} ${arg}"
94 run ffmpeg ${ffmpeg_args}
98 ffmpeg "$@" -flags +bitexact -f framecrc -
102 ffmpeg "$@" -flags +bitexact -f framemd5 -
114 ffmpeg "$@" -vn -f s16le -
121 src_file=$(target_path $4)
123 encfile="${outdir}/${test}.${out_fmt}"
125 encfile=$(target_path ${encfile})
126 ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
127 ffmpeg -flags +bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
130 FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
131 DEC_OPTS="-threads $threads -idct simple $FLAGS"
132 ENC_OPTS="-threads 1 -idct simple -dct fastint"
141 encfile="${outdir}/${test}.${enc_fmt}"
142 decfile="${outdir}/${test}.out.${dec_fmt}"
143 cleanfiles="$cleanfiles $decfile"
144 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
145 tsrcfile=$(target_path $srcfile)
146 tencfile=$(target_path $encfile)
147 tdecfile=$(target_path $decfile)
148 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
149 -f $enc_fmt -y $tencfile || return
151 echo $(wc -c $encfile)
152 ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
153 -f $dec_fmt -y $tdecfile || return
155 tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
159 t="${test#lavf-fate-}"
160 ref=${base}/ref/lavf-fate/$t
161 ${base}/lavf-regression.sh $t lavf-fate tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
166 ref=${base}/ref/lavf/$t
167 ${base}/lavf-regression.sh $t lavf tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
173 label=${test#filter-}
174 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
175 printf '%-20s' $label
176 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
177 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5:
181 pix_fmts="$(ffmpeg -pix_fmts list 2>/dev/null | awk 'NR > 8 && /^IO/ { print $2 }' | sort)"
182 for pix_fmt in $pix_fmts; do
184 video_filter "format=$pix_fmt,pixdesctest" -pix_fmt $pix_fmt
189 filter=${test#filter-pixfmts-}
194 showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
195 scale_exclude_fmts=${outfile}_scale_exclude_fmts
196 scale_in_fmts=${outfile}_scale_in_fmts
197 scale_out_fmts=${outfile}_scale_out_fmts
198 in_fmts=${outfile}_in_fmts
200 # exclude pixel formats which are not supported as input
201 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
202 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
203 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
205 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
206 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
208 for pix_fmt in $pix_fmts; do
210 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt
213 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
218 # Disable globbing: command arguments may contain globbing characters and
219 # must be kept verbatim
223 eval $command >"$outfile" 2>$errfile
226 if [ $err -gt 128 ]; then
227 sig=$(kill -l $err 2>/dev/null)
228 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
231 if test -e "$ref" || test $cmp = "oneline" ; then
233 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
234 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
235 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
236 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
237 null) cat "$outfile" >$cmpfile ;;
240 test $err = 0 && err=$cmperr
241 test $err = 0 || cat $cmpfile
243 echo "reference file '$ref' not found"
247 echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
249 if test $err != 0 && test $gen != "no" ; then
251 cp -f "$outfile" "$ref"
255 if test $err = 0; then
256 rm -f $outfile $errfile $cmpfile $cleanfiles
257 elif test $gen = "no"; then
258 echo "Test $test failed. Look at $errfile for details."
260 echo "Updating reference failed, possibly no output file was generated."