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${PROGSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
91 test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
96 run ffprobe${PROGSUF} -show_frames -v 0 "$@"
100 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
101 ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
103 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
104 ffmpeg_args="${ffmpeg_args} ${arg}"
106 run ffmpeg${PROGSUF} ${ffmpeg_args}
110 ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framecrc -
114 ffmpeg "$@" -flags +bitexact -fflags +bitexact -f framemd5 -
126 ffmpeg "$@" -vn -f s16le -
132 ffmpeg -flags +bitexact -fflags +bitexact "$@" -f $fmt -
139 src_file=$(target_path $4)
141 encfile="${outdir}/${test}.${out_fmt}"
143 encfile=$(target_path ${encfile})
144 ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
145 ffmpeg -flags +bitexact -fflags +bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
148 FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
149 DEC_OPTS="-threads $threads -idct simple $FLAGS"
150 ENC_OPTS="-threads 1 -idct simple -dct fastint"
159 encfile="${outdir}/${test}.${enc_fmt}"
160 decfile="${outdir}/${test}.out.${dec_fmt}"
161 cleanfiles="$cleanfiles $decfile"
162 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
163 tsrcfile=$(target_path $srcfile)
164 tencfile=$(target_path $encfile)
165 tdecfile=$(target_path $decfile)
166 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
167 -f $enc_fmt -y $tencfile || return
169 echo $(wc -c $encfile)
170 ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
171 -f $dec_fmt -y $tdecfile || return
173 tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
177 t="${test#lavf-fate-}"
178 ref=${base}/ref/lavf-fate/$t
179 ${base}/lavf-regression.sh $t lavf-fate tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
184 ref=${base}/ref/lavf/$t
185 ${base}/lavf-regression.sh $t lavf tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
191 label=${test#filter-}
192 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
193 printf '%-20s' $label
194 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
195 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
199 filter=${test#filter-pixfmts-}
205 showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
206 scale_exclude_fmts=${outfile}_scale_exclude_fmts
207 scale_in_fmts=${outfile}_scale_in_fmts
208 scale_out_fmts=${outfile}_scale_out_fmts
209 in_fmts=${outfile}_in_fmts
211 # exclude pixel formats which are not supported as input
212 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
213 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
214 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
216 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
217 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
220 for pix_fmt in $pix_fmts; do
222 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
225 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
230 sample=$(target_path $1)
233 decfile1="${outdir}/${test}.out-1"
234 decfile2="${outdir}/${test}.out-2"
235 decfile3="${outdir}/${test}.out-3"
236 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
239 ffmpeg $extra_args -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile1
241 # test decoded (and cut) data
242 ffmpeg $extra_args -i "$sample" -flags +bitexact -fflags +bitexact -f wav md5:
243 # the same as above again, with seeking to the start
244 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile2
246 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -f wav md5:
247 # test packet data, with seeking to a specific position
248 ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -flags +bitexact -fflags +bitexact -c:a copy -f framecrc -y $decfile3
258 concatfile="${outdir}/${test}.ffconcat"
259 packetfile="${outdir}/${test}.ffprobe"
260 cleanfiles="$concatfile $packetfile"
262 awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
264 if [ "$mode" = "md5" ]; then
265 run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile | tr -d '\r' > $packetfile
266 do_md5sum $packetfile
268 run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile
274 # Disable globbing: command arguments may contain globbing characters and
275 # must be kept verbatim
279 eval $command >"$outfile" 2>$errfile
282 if [ $err -gt 128 ]; then
283 sig=$(kill -l $err 2>/dev/null)
284 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
287 if test -e "$ref" || test $cmp = "oneline" ; then
289 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
290 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
291 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
292 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
293 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
294 null) cat "$outfile" >$cmpfile ;;
297 test $err = 0 && err=$cmperr
298 test $err = 0 || cat $cmpfile
300 echo "reference file '$ref' not found"
304 if [ $err -eq 0 ]; then
307 cmpo="$($base64 <$cmpfile)"
308 erro="$($base64 <$errfile)"
310 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
312 if test $err != 0 && test $gen != "no" ; then
314 cp -f "$outfile" "$ref"
318 if test $err = 0; then
319 rm -f $outfile $errfile $cmpfile $cleanfiles
320 elif test $gen = "no"; then
321 echo "Test $test failed. Look at $errfile for details."
322 test "${V:-0}" -gt 0 && cat $errfile
324 echo "Updating reference failed, possibly no output file was generated."