8 base64=tests/base64${HOSTEXECSUF}
16 ref=${7:-"${base}/ref/fate/${test}"}
19 thread_type=${10:-frame+slice}
23 size_tolerance=${14:-0}
27 report_type=${18:-standard}
30 outdir="tests/data/fate"
31 outfile="${outdir}/${test}"
32 errfile="${outdir}/${test}.err"
33 cmpfile="${outdir}/${test}.diff"
34 repfile="${outdir}/${test}.rep"
37 test ${1} = ${1#/} && p=${target_path}/
41 # $1=value1, $2=value2, $3=threshold
42 # prints 0 if absolute difference between value1 and value2 is <= threshold
44 awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
48 psnr=$(tests/tiny_psnr${HOSTEXECSUF} "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
49 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
50 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
51 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
52 val_cmp=$(compare $val $cmp_target $fuzz)
53 size_cmp=$(compare $size1 $size2 $size_tolerance)
54 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
56 if [ "$val_cmp" != 0 ]; then
57 echo "$3: |$val - $cmp_target| >= $fuzz"
59 if [ "$size_cmp" != 0 ]; then
60 echo "size: |$size1 - $size2| >= $size_tolerance"
67 do_tiny_psnr "$1" "$2" MAXDIFF
71 do_tiny_psnr "$1" "$2" stddev
75 printf '%s\n' "$1" | diff -u -b - "$2"
79 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
80 $target_exec $target_path/"$@"
84 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
85 $target_exec $target_path/"$@" >&3
89 run ffprobe${PROGSUF}${EXECSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
93 run ffprobe${PROGSUF}${EXECSUF} -show_entries format_tags -v 0 "$@"
97 test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
102 run ffprobe${PROGSUF}${EXECSUF} -show_frames -v 0 "$@"
106 run ffprobe${PROGSUF}${EXECSUF} -show_chapters -v 0 "$@"
112 run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts -v 0 "$filename" "$@"
113 pktfile1="${outdir}/${test}.pkts"
114 framefile1="${outdir}/${test}.frames"
115 cleanfiles="$cleanfiles $pktfile1 $framefile1"
116 run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration,flags:stream=nb_read_packets -v 0 "$filename" "$@" > "$pktfile1"
117 head -n 8 "$pktfile1"
118 tail -n 9 "$pktfile1"
119 run ffprobe${PROGSUF}${EXECSUF} -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"
120 head -n 8 "$framefile1"
121 tail -n 9 "$framefile1"
125 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
126 ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
128 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
129 ffmpeg_args="${ffmpeg_args} ${arg}"
131 run ffmpeg${PROGSUF}${EXECSUF} ${ffmpeg_args}
135 ffmpeg "$@" -bitexact -f framecrc -
139 ffmpeg "$@" -bitexact -f ffmetadata -
143 ffmpeg "$@" -bitexact -f framemd5 -
155 encfile="${outdir}/${test}.out"
156 cleanfiles="$cleanfiles $encfile"
157 ffmpeg "$@" $(target_path $encfile)
158 do_md5sum $encfile | awk '{print $1}'
162 ffmpeg "$@" -vn -f s16le -
168 ffmpeg -bitexact "$@" -f $fmt -
175 src_file=$(target_path $4)
177 encfile="${outdir}/${test}.${out_fmt}"
179 encfile=$(target_path ${encfile})
180 ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
181 ffmpeg -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
184 FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
185 DEC_OPTS="-threads $threads -idct simple $FLAGS"
186 ENC_OPTS="-threads 1 -idct simple -dct fastint"
195 encfile="${outdir}/${test}.${enc_fmt}"
196 decfile="${outdir}/${test}.out.${dec_fmt}"
197 cleanfiles="$cleanfiles $decfile"
198 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
199 tsrcfile=$(target_path $srcfile)
200 tencfile=$(target_path $encfile)
201 tdecfile=$(target_path $decfile)
202 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
203 -f $enc_fmt -y $tencfile || return
205 echo $(wc -c $encfile)
206 ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
207 -f $dec_fmt -y $tdecfile || return
209 tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
218 encfile="${outdir}/${test}.${enc_fmt}"
219 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
220 tsrcfile=$(target_path $srcfile)
221 tencfile=$(target_path $encfile)
222 ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
223 -f $enc_fmt -y $tencfile || return
225 echo $(wc -c $encfile)
226 ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
227 -f framecrc - || return
236 encfile="${outdir}/${test}.${enc_fmt}"
237 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
238 tsrcfile=$(target_path $srcfile)
239 tencfile=$(target_path $encfile)
240 ffmpeg -f $src_fmt -i $tsrcfile $stream_maps -codec copy $FLAGS \
241 -f $enc_fmt -y $tencfile || return
242 ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
243 -f framecrc - || return
246 # FIXME: There is a certain duplication between the avconv-related helper
247 # functions above and below that should be refactored.
248 ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
249 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
250 pcm_src="${target_path}/tests/data/asynth1.sw"
251 crcfile="tests/data/$test.lavf.crc"
252 target_crcfile="${target_path}/$crcfile"
254 [ "${V-0}" -gt 0 ] && echov=echov || echov=:
260 AVCONV_OPTS="-nostdin -nostats -y -cpuflags $cpuflags"
261 COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
262 DEC_OPTS="$COMMON_OPTS -threads $threads"
263 ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
266 $echov $ffmpeg2 $AVCONV_OPTS $*
267 $ffmpeg2 $AVCONV_OPTS $*
273 set -- $* ${target_path}/$f
282 run_avconv $* -f crc "$target_crcfile"
283 echo "$f $(cat $crcfile)"
288 outdir="tests/data/lavf"
289 file=${outdir}/lavf.$t
290 do_avconv $file $DEC_OPTS $1 -ar 44100 -f s16le -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $2
291 do_avconv_crc $file $DEC_OPTS $3 -i $target_path/$file
296 outdir="tests/data/lavf"
297 file=${outdir}/lavf.$t
298 do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le $1 -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -b:a 64k -t 1 -qscale:v 10 $2
299 test "$3" = "disable_crc" ||
300 do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
303 lavf_container_attach() { lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
304 lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
305 lavf_container_timecode_drop() { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }
307 lavf_container_timecode()
309 lavf_container_timecode_nodrop "$@"
310 lavf_container_timecode_drop "$@"
311 lavf_container "" "$1"
314 lavf_container_fate()
316 t="${test#lavf-fate-}"
317 outdir="tests/data/lavf-fate"
318 file=${outdir}/lavf.$t
319 input="${target_samples}/$1"
320 do_avconv $file $DEC_OPTS $2 -i "$input" "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy
321 do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
326 outdir="tests/data/images/$t"
328 file=${outdir}/%02d.$t
329 run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 "$ENC_OPTS -metadata title=lavftest" -frames 13 -y -qscale 10 $target_path/$file
330 do_md5sum ${outdir}/02.$t
331 do_avconv_crc $file $DEC_OPTS $2 -i $target_path/$file $2
332 echo $(wc -c ${outdir}/02.$t)
338 outdir="tests/data/lavf"
339 file=${outdir}/${t}pipe.$t
340 do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src -f image2pipe "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10
341 do_avconv_crc $file $DEC_OPTS -f image2pipe -i $target_path/$file
346 outdir="tests/data/lavf"
347 file=${outdir}/lavf.$t
348 do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $1 $2
349 do_avconv_crc $file $DEC_OPTS -i $target_path/$file $1
356 ffmpeg $FLAGS $ENC_OPTS \
357 -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
358 -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
362 conversion="${test#pixfmt-}"
363 outdir="tests/data/pixfmt"
364 raw_dst="$outdir/$conversion.out.yuv"
365 file=${outdir}/${conversion}.yuv
366 run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
367 $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst
368 do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
369 $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
375 label=${test#filter-}
376 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
377 printf '%-20s' $label
378 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
379 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
383 filter=${test#filter-pixfmts-}
389 showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
390 scale_exclude_fmts=${outfile}_scale_exclude_fmts
391 scale_in_fmts=${outfile}_scale_in_fmts
392 scale_out_fmts=${outfile}_scale_out_fmts
393 in_fmts=${outfile}_in_fmts
395 # exclude pixel formats which are not supported as input
396 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
397 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
398 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
400 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
401 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
404 for pix_fmt in $pix_fmts; do
406 video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
409 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
414 sample=$(target_path $1)
417 decfile1="${outdir}/${test}.out-1"
418 decfile2="${outdir}/${test}.out-2"
419 decfile3="${outdir}/${test}.out-3"
420 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
423 ffmpeg $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile1)
425 # test decoded (and cut) data
426 ffmpeg $extra_args -i "$sample" -bitexact -f wav md5:
427 # the same as above again, with seeking to the start
428 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile2)
430 ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
431 # test packet data, with seeking to a specific position
432 ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile3)
437 sample=$(target_path $1)
441 file1="${outdir}/${test}.out-1"
442 cleanfiles="$cleanfiles $file1"
444 # test data after reencoding
445 ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -f $format -y "$(target_path "$file1")"
446 probegaplessinfo "$(target_path "$file1")"
450 sample=$(target_path $1)
454 decfile="${outdir}/${test}.wav"
455 cleanfiles="$cleanfiles $decfile"
457 ffmpeg -i "$sample" -bitexact $extra_args -y $(target_path $decfile)
458 tests/audiomatch${HOSTEXECSUF} $decfile $trefile
467 concatfile="${outdir}/${test}.ffconcat"
468 packetfile="${outdir}/${test}.ffprobe"
469 cleanfiles="$concatfile $packetfile"
471 awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
473 if [ "$mode" = "md5" ]; then
474 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -safe 0 $extra_args $(target_path $concatfile) | tr -d '\r' > $packetfile
475 do_md5sum $packetfile
477 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -safe 0 $extra_args $(target_path $concatfile)
485 # Disable globbing: command arguments may contain globbing characters and
486 # must be kept verbatim
490 eval $command >"$outfile" 2>$errfile
493 if [ $err -gt 128 ]; then
494 sig=$(kill -l $err 2>/dev/null)
495 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
498 if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
500 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
501 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
502 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
503 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
504 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
505 grep) grep "$ref" "$errfile" >$cmpfile ;;
506 null) cat "$outfile" >$cmpfile ;;
509 test $err = 0 && err=$cmperr
510 if [ "$report_type" = "ignore" ]; then
511 test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
513 test $err = 0 || cat $cmpfile
516 echo "reference file '$ref' not found"
520 if [ $err -eq 0 ] && test $report_type = "standard" ; then
523 cmpo="$($base64 <$cmpfile)"
524 erro="$($base64 <$errfile)"
526 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
528 if test $err != 0 && test $gen != "no" ; then
530 cp -f "$outfile" "$ref"
534 if test $err = 0; then
535 if test $keep = 0; then
536 rm -f $outfile $errfile $cmpfile $cleanfiles
538 elif test $gen = "no"; then
539 echo "Test $test failed. Look at $errfile for details."
540 test "${V:-0}" -gt 0 && cat $errfile
542 echo "Updating reference failed, possibly no output file was generated."