16 ref=${7:-"${base}/ref/fate/${test}"}
19 thread_type=${10:-frame+slice}
23 size_tolerance=${14:-0}
27 report_type=${18:-standard}
29 outdir="tests/data/fate"
30 outfile="${outdir}/${test}"
31 errfile="${outdir}/${test}.err"
32 cmpfile="${outdir}/${test}.diff"
33 repfile="${outdir}/${test}.rep"
36 test ${1} = ${1#/} && p=${target_path}/
40 # $1=value1, $2=value2, $3=threshold
41 # prints 0 if absolute difference between value1 and value2 is <= threshold
43 awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
47 psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
48 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
49 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
50 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
51 val_cmp=$(compare $val $cmp_target $fuzz)
52 size_cmp=$(compare $size1 $size2 $size_tolerance)
53 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
55 if [ "$val_cmp" != 0 ]; then
56 echo "$3: |$val - $cmp_target| >= $fuzz"
58 if [ "$size_cmp" != 0 ]; then
59 echo "size: |$size1 - $size2| >= $size_tolerance"
66 do_tiny_psnr "$1" "$2" MAXDIFF
70 do_tiny_psnr "$1" "$2" stddev
74 printf '%s\n' "$1" | diff -u -b - "$2"
78 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
79 $target_exec $target_path/"$@"
83 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
84 $target_exec $target_path/"$@" >&3
88 run ffprobe${PROGSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
92 run ffprobe${PROGSUF} -show_entries format_tags -v 0 "$@"
96 test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
101 run ffprobe${PROGSUF} -show_frames -v 0 "$@"
105 run ffprobe${PROGSUF} -show_chapters -v 0 "$@"
111 run ffprobe${PROGSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts -v 0 "$filename" "$@"
112 pktfile1="${outdir}/${test}.pkts"
113 framefile1="${outdir}/${test}.frames"
114 cleanfiles="$cleanfiles $pktfile1 $framefile1"
115 run ffprobe${PROGSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration,flags:stream=nb_read_packets -v 0 "$filename" "$@" > "$pktfile1"
116 head -n 8 "$pktfile1"
117 tail -n 9 "$pktfile1"
118 run ffprobe${PROGSUF} -bitexact -select_streams a -of compact -count_frames -show_entries frame=pkt_pts,pkt_dts,best_effort_timestamp,pkt_duration,nb_samples:stream=nb_read_frames -v 0 "$filename" "$@" > "$framefile1"
119 head -n 8 "$framefile1"
120 tail -n 9 "$framefile1"
124 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
125 ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
127 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
128 ffmpeg_args="${ffmpeg_args} ${arg}"
130 run ffmpeg${PROGSUF} ${ffmpeg_args}
134 ffmpeg "$@" -bitexact -f framecrc -
138 ffmpeg "$@" -bitexact -f ffmetadata -
142 ffmpeg "$@" -bitexact -f framemd5 -
154 encfile="${outdir}/${test}.out"
155 cleanfiles="$cleanfiles $encfile"
157 do_md5sum $encfile | awk '{print $1}'
161 ffmpeg "$@" -vn -f s16le -
167 ffmpeg -bitexact "$@" -f $fmt -
174 src_file=$(target_path $4)
176 encfile="${outdir}/${test}.${out_fmt}"
178 encfile=$(target_path ${encfile})
179 ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
180 ffmpeg -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
183 FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
184 DEC_OPTS="-threads $threads -idct simple $FLAGS"
185 ENC_OPTS="-threads 1 -idct simple -dct fastint"
194 encfile="${outdir}/${test}.${enc_fmt}"
195 decfile="${outdir}/${test}.out.${dec_fmt}"
196 cleanfiles="$cleanfiles $decfile"
197 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
198 tsrcfile=$(target_path $srcfile)
199 tencfile=$(target_path $encfile)
200 tdecfile=$(target_path $decfile)
201 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
202 -f $enc_fmt -y $tencfile || return
204 echo $(wc -c $encfile)
205 ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
206 -f $dec_fmt -y $tdecfile || return
208 tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
217 encfile="${outdir}/${test}.${enc_fmt}"
218 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
219 tsrcfile=$(target_path $srcfile)
220 tencfile=$(target_path $encfile)
221 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
222 -f $enc_fmt -y $tencfile || return
224 echo $(wc -c $encfile)
225 ffmpeg $DEC_OPTS -i $encfile $ENC_OPTS $FLAGS $final_decode \
226 -f framecrc - || return
235 encfile="${outdir}/${test}.${enc_fmt}"
236 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
237 tsrcfile=$(target_path $srcfile)
238 tencfile=$(target_path $encfile)
239 ffmpeg -f $src_fmt -i $tsrcfile $stream_maps -codec copy $FLAGS \
240 -f $enc_fmt -y $tencfile || return
241 ffmpeg $DEC_OPTS -i $encfile $ENC_OPTS $FLAGS $final_decode \
242 -f framecrc - || return
246 t="${test#lavf-fate-}"
247 ref=${base}/ref/lavf-fate/$t
248 ${base}/lavf-regression.sh $t lavf-fate tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
253 ref=${base}/ref/lavf/$t
254 ${base}/lavf-regression.sh $t lavf tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags" "$target_samples"
261 ffmpeg $FLAGS $ENC_OPTS \
262 -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
263 -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
269 label=${test#filter-}
270 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
271 printf '%-20s' $label
272 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
273 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
277 filter=${test#filter-pixfmts-}
283 showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts"
284 scale_exclude_fmts=${outfile}_scale_exclude_fmts
285 scale_in_fmts=${outfile}_scale_in_fmts
286 scale_out_fmts=${outfile}_scale_out_fmts
287 in_fmts=${outfile}_in_fmts
289 # exclude pixel formats which are not supported as input
290 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
291 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
292 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
294 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
295 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
298 for pix_fmt in $pix_fmts; do
300 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
303 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
308 sample=$(target_path $1)
311 decfile1="${outdir}/${test}.out-1"
312 decfile2="${outdir}/${test}.out-2"
313 decfile3="${outdir}/${test}.out-3"
314 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
317 ffmpeg $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile1
319 # test decoded (and cut) data
320 ffmpeg $extra_args -i "$sample" -bitexact -f wav md5:
321 # the same as above again, with seeking to the start
322 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile2
324 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
325 # test packet data, with seeking to a specific position
326 ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile3
331 sample=$(target_path $1)
335 file1="${outdir}/${test}.out-1"
336 cleanfiles="$cleanfiles $file1"
338 # test data after reencoding
339 ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -f $format -y "$file1"
340 probegaplessinfo "$file1"
344 sample=$(target_path $1)
345 trefile=$(target_path $2)
348 decfile="${outdir}/${test}.wav"
349 cleanfiles="$cleanfiles $decfile"
351 ffmpeg -i "$sample" -bitexact $extra_args -y $decfile
352 tests/audiomatch $decfile $trefile
361 concatfile="${outdir}/${test}.ffconcat"
362 packetfile="${outdir}/${test}.ffprobe"
363 cleanfiles="$concatfile $packetfile"
365 awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
367 if [ "$mode" = "md5" ]; then
368 run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile | tr -d '\r' > $packetfile
369 do_md5sum $packetfile
371 run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile
381 # Disable globbing: command arguments may contain globbing characters and
382 # must be kept verbatim
386 eval $command >"$outfile" 2>$errfile
389 if [ $err -gt 128 ]; then
390 sig=$(kill -l $err 2>/dev/null)
391 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
394 if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
396 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
397 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
398 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
399 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
400 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
401 grep) grep "$ref" "$errfile" >$cmpfile ;;
402 null) cat "$outfile" >$cmpfile ;;
405 test $err = 0 && err=$cmperr
406 if [ "$report_type" = "ignore" ]; then
407 test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
409 test $err = 0 || cat $cmpfile
412 echo "reference file '$ref' not found"
416 if [ $err -eq 0 ] && test $report_type = "standard" ; then
419 cmpo="$($base64 <$cmpfile)"
420 erro="$($base64 <$errfile)"
422 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
424 if test $err != 0 && test $gen != "no" ; then
426 cp -f "$outfile" "$ref"
430 if test $err = 0; then
431 rm -f $outfile $errfile $cmpfile $cleanfiles
432 elif test $gen = "no"; then
433 echo "Test $test failed. Look at $errfile for details."
434 test "${V:-0}" -gt 0 && cat $errfile
436 echo "Updating reference failed, possibly no output file was generated."