avcodec/hevc/hevcdec: Don't add to null pointer
[FFMpeg-mirror.git] / tests / fate-run.sh
blob45dcb6e8dc4e21c44002f701d5a55d74d9998b68
1 #!/bin/sh
3 export LC_ALL=C
5 base=$(dirname $0)
6 . "${base}/md5.sh"
8 base64=tests/base64${HOSTEXECSUF}
10 test="${1#fate-}"
11 target_samples=$2
12 target_exec=$3
13 target_path=$4
14 command=$5
15 cmp=${6:-diff}
16 ref=${7:-"${base}/ref/fate/${test}"}
17 fuzz=${8:-1}
18 threads=${9:-1}
19 thread_type=${10:-frame+slice}
20 cpuflags=${11:-all}
21 cmp_shift=${12:-0}
22 cmp_target=${13:-0}
23 size_tolerance=${14:-0}
24 cmp_unit=${15:-2}
25 gen=${16:-no}
26 hwaccel=${17:-none}
27 report_type=${18:-standard}
28 keep=${19:-0}
30 outdir="tests/data/fate"
31 outfile="${outdir}/${test}"
32 errfile="${outdir}/${test}.err"
33 cmpfile="${outdir}/${test}.diff"
34 repfile="${outdir}/${test}.rep"
36 case $threads in
37 random*)
38 threads_max=${threads#random}
39 [ -z "$threads_max" ] && threads_max=16
40 threads=$(awk "BEGIN { srand(); print 1+int(rand() * $threads_max) }" < /dev/null)
42 esac
45 target_path(){
46 test ${1} = ${1#/} && p=${target_path}/
47 echo ${p}${1}
50 # $1=value1, $2=value2, $3=threshold
51 # prints 0 if absolute difference between value1 and value2 is <= threshold
52 compare(){
53 awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
56 do_tiny_psnr(){
57 psnr=$(tests/tiny_psnr${HOSTEXECSUF} "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
58 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
59 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
60 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
61 val_cmp=$(compare $val $cmp_target $fuzz)
62 size_cmp=$(compare $size1 $size2 $size_tolerance)
63 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
64 echo "$psnr"
65 if [ "$val_cmp" != 0 ]; then
66 echo "$3: |$val - $cmp_target| >= $fuzz"
68 if [ "$size_cmp" != 0 ]; then
69 echo "size: |$size1 - $size2| >= $size_tolerance"
71 return 1
75 oneoff(){
76 do_tiny_psnr "$1" "$2" MAXDIFF
79 stddev(){
80 do_tiny_psnr "$1" "$2" stddev
83 oneline(){
84 printf '%s\n' "$1" | diff -u -b - "$2"
87 run(){
88 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
89 $target_exec $target_path/"$@"
92 runecho(){
93 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
94 $target_exec $target_path/"$@" >&3
97 probefmt(){
98 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries format=format_name -print_format default=nw=1:nk=1 "$@"
101 probeaudiostream(){
102 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries stream=codec_name,codec_time_base,sample_fmt,channels,channel_layout:side_data "$@"
105 probetags(){
106 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries format_tags "$@"
109 runlocal(){
110 test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
111 ${base}/"$@" ${base}
114 probeframes(){
115 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_frames "$@"
118 probechapters(){
119 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_chapters "$@"
122 probegaplessinfo(){
123 filename="$1"
124 shift
125 run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts "$filename" "$@"
126 pktfile1="${outdir}/${test}.pkts"
127 framefile1="${outdir}/${test}.frames"
128 cleanfiles="$cleanfiles $pktfile1 $framefile1"
129 run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration,flags:stream=nb_read_packets "$filename" "$@" > "$pktfile1"
130 head -n 8 "$pktfile1"
131 tail -n 9 "$pktfile1"
132 run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -of compact -count_frames -show_entries frame=pts,pkt_dts,best_effort_timestamp,pkt_duration,nb_samples:stream=nb_read_frames "$filename" "$@" > "$framefile1"
133 head -n 8 "$framefile1"
134 tail -n 9 "$framefile1"
137 ffmpeg(){
138 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
139 ffmpeg_args="-nostdin -nostats -noauto_conversion_filters -cpuflags $cpuflags"
140 for arg in $@; do
141 [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
142 ffmpeg_args="${ffmpeg_args} ${arg}"
143 done
144 run ffmpeg${PROGSUF}${EXECSUF} ${ffmpeg_args}
147 ffprobe_demux(){
148 filename=$1
149 shift
150 print_filename=$(basename "$filename")
151 run ffprobe${PROGSUF}${EXECSUF} -print_filename "${print_filename}" \
152 -of compact -bitexact -show_format -show_streams -show_packets \
153 -show_data_hash CRC32 "$filename" "$@"
156 framecrc(){
157 ffmpeg "$@" -bitexact -f framecrc -
160 ffmetadata(){
161 ffmpeg "$@" -bitexact -f ffmetadata -
164 framemd5(){
165 ffmpeg "$@" -bitexact -f framemd5 -
168 crc(){
169 ffmpeg "$@" -f crc -
172 md5pipe(){
173 ffmpeg "$@" md5:
176 md5(){
177 encfile="${outdir}/${test}.out"
178 cleanfiles="$cleanfiles $encfile"
179 ffmpeg -y "$@" $(target_path $encfile) || return
180 do_md5sum $encfile | awk '{print $1}'
183 pcm(){
184 ffmpeg -auto_conversion_filters "$@" -vn -f s16le -
187 fmtstdout(){
188 fmt=$1
189 shift 1
190 ffmpeg -bitexact "$@" -bitexact -f $fmt -
193 enc_dec_pcm(){
194 out_fmt=$1
195 dec_fmt=$2
196 pcm_fmt=$3
197 src_file=$(target_path $4)
198 shift 4
199 encfile="${outdir}/${test}.${out_fmt}"
200 cleanfiles=$encfile
201 encfile=$(target_path ${encfile})
202 ffmpeg -auto_conversion_filters -i $src_file "$@" -f $out_fmt -y ${encfile} || return
203 ffmpeg -auto_conversion_filters -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
206 SCALE_FLAGS="+accurate_rnd+bitexact"
207 FLAGS="-flags +bitexact -sws_flags $SCALE_FLAGS -fflags +bitexact"
208 DEC_OPTS="-threads $threads -thread_type $thread_type -idct simple $FLAGS"
209 ENC_OPTS="-threads 1 -idct simple -dct fastint"
211 enc_dec(){
212 enc_fmt_in=$1
213 srcfile=$2
214 enc_fmt_out=$3
215 enc_opt_out=$4
216 dec_fmt_out=$5
217 dec_opt_out=$6
218 dec_opt_in=$7
219 ffprobe_opts=$8
220 twopass=$9
221 encfile="${outdir}/${test}.${enc_fmt_out}"
222 decfile="${outdir}/${test}.out.${dec_fmt_out}"
223 cleanfiles="$cleanfiles $decfile"
224 test "$keep" -ge 1 || cleanfiles="$cleanfiles $encfile"
225 tsrcfile=$(target_path $srcfile)
226 tencfile=$(target_path $encfile)
227 tdecfile=$(target_path $decfile)
229 if [ -n "$twopass" ]; then
230 logfile_prefix="${outdir}/${test}.pass1"
231 cleanfiles="$cleanfiles ${logfile_prefix}-0.log"
232 tlogfile_prefix=$(target_path $logfile_prefix)
233 ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile \
234 $ENC_OPTS $enc_opt_out $FLAGS -pass 1 -passlogfile $tlogfile_prefix \
235 -f $enc_fmt_out -y $tencfile || return
236 enc_opt_out="$enc_opt_out -pass 2 -passlogfile $tlogfile_prefix"
239 ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt_out $FLAGS \
240 -f $enc_fmt_out -y $tencfile || return
241 do_md5sum $encfile
242 echo $(wc -c $encfile)
243 ffmpeg -auto_conversion_filters $dec_opt_in $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt_out $FLAGS \
244 -f $dec_fmt_out -y $tdecfile || return
245 do_md5sum $decfile
246 tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
247 test -z "$ffprobe_opts" || \
248 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
251 transcode(){
252 src_fmt=$1
253 srcfile=$2
254 enc_fmt=$3
255 enc_opt=$4
256 final_encode=$5
257 ffprobe_opts=$6
258 additional_input=$7
259 final_decode=$8
260 enc_opt_in=$9
261 test -z "$additional_input" || additional_input="$DEC_OPTS $additional_input"
262 encfile="${outdir}/${test}.${enc_fmt}"
263 test $keep -ge 1 || cleanfiles="$cleanfiles $encfile"
264 tsrcfile=$(target_path $srcfile)
265 tencfile=$(target_path $encfile)
266 ffmpeg -f $src_fmt $DEC_OPTS $enc_opt_in -i $tsrcfile $additional_input \
267 $ENC_OPTS $enc_opt $FLAGS -f $enc_fmt -y $tencfile || return
268 do_md5sum $encfile
269 echo $(wc -c $encfile)
270 ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode \
271 -f framecrc - || return
272 test -z "$ffprobe_opts" || \
273 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
276 stream_demux(){
277 src_fmt=$1
278 srcfile=$2
279 src_opts=$3
280 enc_opts=$4
281 ffprobe_opts=$5
282 tsrcfile=$(target_path $srcfile)
283 ffmpeg $DEC_OPTS -f $src_fmt $src_opts -i $tsrcfile $ENC_OPTS $FLAGS $enc_opts \
284 -f framecrc - || return
285 test -z "$ffprobe_opts" || \
286 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tsrcfile || return
289 stream_remux(){
290 src_fmt=$1
291 srcfile=$2
292 src_opts=$3
293 enc_fmt=$4
294 stream_maps=$5
295 final_decode=$6
296 final_encode=$7
297 ffprobe_opts=$8
298 encfile="${outdir}/${test}.${enc_fmt}"
299 test $keep -ge 1 || cleanfiles="$cleanfiles $encfile"
300 tsrcfile=$(target_path $srcfile)
301 tencfile=$(target_path $encfile)
302 ffmpeg -f $src_fmt $src_opts -i $tsrcfile $stream_maps -codec copy $FLAGS \
303 -f $enc_fmt -y $tencfile || return
304 ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode \
305 -f framecrc - || return
306 test -z "$ffprobe_opts" || \
307 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
310 # this function is for testing external encoders,
311 # where the precise output is not controlled by us
312 # we can still test e.g. that the output can be decoded correctly
313 enc_external(){
314 srcfile=$1
315 enc_fmt=$2
316 enc_opt=$3
317 probe_opt=$4
319 srcfile=$(target_path $srcfile)
320 encfile=$(target_path "${outdir}/${test}.${enc_fmt}")
322 ffmpeg -i $srcfile $enc_opt -f $enc_fmt -y $encfile || return
323 run ffprobe${PROGSUF}${EXECSUF} -bitexact $probe_opt $encfile || return
326 # FIXME: There is a certain duplication between the avconv-related helper
327 # functions above and below that should be refactored.
328 ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
329 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
330 pcm_src="${target_path}/tests/data/asynth1.sw"
332 [ "${V-0}" -gt 0 ] && echov=echov || echov=:
334 echov(){
335 echo "$@" >&3
338 AVCONV_OPTS="-nostdin -nostats -noauto_conversion_filters -y -cpuflags $cpuflags -filter_threads $threads"
339 COMMON_OPTS="-flags +bitexact -idct simple -sws_flags $SCALE_FLAGS -fflags +bitexact"
340 DEC_OPTS="$COMMON_OPTS -threads $threads"
341 ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
343 run_avconv(){
344 $echov $ffmpeg2 $AVCONV_OPTS $*
345 $ffmpeg2 $AVCONV_OPTS $*
348 do_avconv(){
349 f="$1"
350 shift
351 set -- $* ${target_path}/$f
352 run_avconv $* || return
353 do_md5sum $f
354 echo $(wc -c $f)
357 do_avconv_crc(){
358 f="$1"
359 shift
360 printf "%s " "$f"
361 run_avconv $* -f crc -
364 lavf_audio(){
365 t="${test#lavf-}"
366 outdir="tests/data/lavf"
367 file=${outdir}/lavf.$t
368 test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
369 do_avconv $file -auto_conversion_filters $DEC_OPTS $1 -ar 44100 -f s16le -i $pcm_src \
370 "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $2 || return
371 test "$4" = "disable_crc" ||
372 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $3 -i $target_path/$file
375 lavf_container(){
376 t="${test#lavf-}"
377 outdir="tests/data/lavf"
378 file=${outdir}/lavf.$t
379 test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
380 do_avconv $file -auto_conversion_filters $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $DEC_OPTS \
381 -ar 44100 -f s16le $1 -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -b:a 64k -t 1 -qscale:v 10 $2 || return
382 test "$3" = "disable_crc" ||
383 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $3
386 lavf_container_attach() { lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
387 lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
388 lavf_container_timecode_drop() { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }
390 lavf_container_timecode()
392 lavf_container_timecode_nodrop "$@"
393 lavf_container_timecode_drop "$@"
394 lavf_container "" "$1"
397 lavf_container_fate()
399 t="${test#lavf-fate-}"
400 outdir="tests/data/lavf-fate"
401 file=${outdir}/lavf.$t
402 cleanfiles="$cleanfiles $file"
403 input="${target_samples}/$1"
404 do_avconv $file -auto_conversion_filters $DEC_OPTS $2 -i "$input" \
405 "$ENC_OPTS -metadata title=lavftest" $3 -vcodec copy -acodec copy || return
406 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $4
409 lavf_image(){
410 no_file_checksums="$3"
411 nb_frames=13
412 t="${test#lavf-}"
413 outdir="tests/data/images/$t"
414 mkdir -p "$outdir"
415 file=${outdir}/%02d.$t
416 if [ "$keep" -lt 1 ]; then
417 for i in `seq $nb_frames`; do
418 filename=`printf "$file" $i`
419 cleanfiles="$cleanfiles $filename"
420 done
422 run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 \
423 "$ENC_OPTS -metadata title=lavftest" -vf scale -frames $nb_frames \
424 -y -qscale 10 $target_path/$file || return
425 if [ -z "$no_file_checksums" ]; then
426 do_md5sum ${outdir}/02.$t
427 echo $(wc -c ${outdir}/02.$t)
429 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $2 -i $target_path/$file $2
432 lavf_image2pipe(){
433 t="${test#lavf-}"
434 t="${t%pipe}"
435 outdir="tests/data/lavf"
436 file=${outdir}/${t}pipe.$t
437 do_avconv $file -auto_conversion_filters $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src \
438 -f image2pipe "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 || return
439 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -f image2pipe -i $target_path/$file
442 lavf_video(){
443 t="${test#lavf-}"
444 outdir="tests/data/lavf"
445 file=${outdir}/lavf.$t
446 test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
447 do_avconv $file -auto_conversion_filters $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src \
448 "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $1 $2 || return
449 do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $1
452 refcmp_metadata(){
453 refcmp=$1
454 pixfmt=$2
455 fuzz=${3:-0.001}
456 ffmpeg -auto_conversion_filters $FLAGS $ENC_OPTS \
457 -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
458 -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
461 cmp_metadata(){
462 refcmp=$1
463 pixfmt=$2
464 fuzz=${3:-0.001}
465 ffmpeg $FLAGS $ENC_OPTS \
466 -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},${refcmp},metadata=print:file=-" \
467 -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
470 refcmp_metadata_files(){
471 file1=$1
472 file2=$2
473 refcmp=$3
474 pixfmt=$4
475 fuzz=${5:-0.001}
476 ffmpeg -auto_conversion_filters $FLAGS -i $file1 $FLAGS -i $file2 $ENC_OPTS \
477 -lavfi "[0:v]format=${pixfmt}[v0];[1:v]format=${pixfmt}[v1];[v0][v1]${refcmp},metadata=print:file=-" \
478 -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
481 refcmp_metadata_transcode(){
482 srcfile=$1
483 enc_opt=$2
484 enc_fmt=$3
485 enc_ext=$4
486 shift 4
487 encfile="${outdir}/${test}.${enc_ext}"
488 cleanfiles="$cleanfiles $encfile"
489 tsrcfile=$(target_path $srcfile)
490 tencfile=$(target_path $encfile)
491 ffmpeg $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS -y -f $enc_fmt $tencfile || return
492 refcmp_metadata_files $tencfile $tsrcfile "$@"
495 pixfmt_conversion(){
496 conversion="${test#pixfmt-}"
497 outdir="tests/data/pixfmt"
498 raw_dst="$outdir/$conversion.out.yuv"
499 file=${outdir}/${conversion}.yuv
500 cleanfiles="$cleanfiles $raw_dst $file"
501 run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
502 $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst || return
503 do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
504 $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p -color_range mpeg
507 pixfmt_conversion_ext(){
508 prefix=$1
509 suffix=$2
510 color_range="${test#pixfmt-}"
511 color_range=${color_range%-*}
512 conversion="${test#pixfmt-$color_range-}"
513 outdir="tests/data/pixfmt"
514 file=${outdir}/${color_range}-${conversion}.yuv
515 cleanfiles="$cleanfiles $file"
516 do_avconv $file $DEC_OPTS -lavfi ${prefix}testsrc=s=352x288,format=${color_range},scale=flags=$SCALE_FLAGS:sws_dither=none,format=$conversion \
517 $ENC_OPTS -t 1 -f rawvideo -s 352x288 -pix_fmt ${color_range}${suffix} -color_range mpeg
520 pixdesc(){
521 pix_fmt=${test#filter-pixdesc-}
522 label=${test#filter-}
523 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
525 md5file1="${outdir}/${test}-1.md5"
526 md5file2="${outdir}/${test}-2.md5"
527 cleanfiles="$cleanfiles $md5file1 $md5file2"
529 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
530 $FLAGS $ENC_OPTS -vf "scale,format=$pix_fmt" -vcodec rawvideo -frames:v 5 \
531 "-pix_fmt $pix_fmt" -f nut md5:$md5file1
532 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
533 $FLAGS $ENC_OPTS -vf "scale,format=$pix_fmt,pixdesctest" -vcodec rawvideo -frames:v 5 \
534 "-pix_fmt $pix_fmt" -f nut md5:$md5file2
536 diff -q $md5file1 $md5file2 || return
537 printf '%-20s' $label
538 cat $md5file1
541 video_filter(){
542 filters=$1
543 shift
544 label=${test#filter-}
545 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
546 printf '%-20s' $label
547 ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
548 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
551 pixfmts(){
552 filter=${test#filter-pixfmts-}
553 filter=${filter%_*}
554 filter_args=$1
555 prefilter_chain=$2
556 nframes=${3:-1}
558 showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
559 scale_exclude_fmts=${outfile}_scale_exclude_fmts
560 scale_in_fmts=${outfile}_scale_in_fmts
561 scale_out_fmts=${outfile}_scale_out_fmts
562 in_fmts=${outfile}_in_fmts
564 # exclude pixel formats which are not supported as input
565 $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
566 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
567 comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
569 $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
570 pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
572 outertest=$test
573 for pix_fmt in $pix_fmts; do
574 test=$pix_fmt
575 video_filter "${prefilter_chain}scale,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes || return
576 done
578 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
579 test=$outertest
582 gapless(){
583 sample=$(target_path $1)
584 extra_args=$2
586 decfile1="${outdir}/${test}.out-1"
587 decfile2="${outdir}/${test}.out-2"
588 decfile3="${outdir}/${test}.out-3"
589 cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
591 # test packet data
592 ffmpeg -auto_conversion_filters $extra_args -i "$sample" \
593 -bitexact -c:a copy -f framecrc -y $(target_path $decfile1) || return
594 do_md5sum $decfile1
595 # test decoded (and cut) data
596 ffmpeg -auto_conversion_filters $extra_args -i "$sample" -bitexact -f wav md5: || return
597 # the same as above again, with seeking to the start
598 ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" \
599 -bitexact -c:a copy -f framecrc -y $(target_path $decfile2) || return
600 do_md5sum $decfile2
601 ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" \
602 -bitexact -f wav md5: || return
603 # test packet data, with seeking to a specific position
604 ffmpeg -auto_conversion_filters $extra_args -ss 5 -seek_timestamp 1 -i "$sample" \
605 -bitexact -c:a copy -f framecrc -y $(target_path $decfile3) || return
606 do_md5sum $decfile3
609 gaplessenc(){
610 sample=$(target_path $1)
611 format=$2
612 codec=$3
614 file1="${outdir}/${test}.out-1"
615 cleanfiles="$cleanfiles $file1"
617 # test data after reencoding
618 ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -af aresample \
619 -f $format -y "$(target_path "$file1")" || return
620 probegaplessinfo "$(target_path "$file1")"
623 audio_match(){
624 sample=$(target_path $1)
625 trefile=$2
626 extra_args=$3
628 decfile="${outdir}/${test}.wav"
629 cleanfiles="$cleanfiles $decfile"
631 ffmpeg -auto_conversion_filters -i "$sample" -bitexact $extra_args -y $(target_path $decfile) || return
632 tests/audiomatch${HOSTEXECSUF} $decfile $trefile
635 concat(){
636 template=$1
637 sample=$2
638 mode=$3
639 extra_args=$4
641 concatfile="${outdir}/${test}.ffconcat"
642 packetfile="${outdir}/${test}.ffprobe"
643 cleanfiles="$concatfile $packetfile"
645 awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
647 if [ "$mode" = "md5" ]; then
648 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -safe 0 $extra_args $(target_path $concatfile) | tr -d '\r' > $packetfile
649 do_md5sum $packetfile
650 else
651 run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -of compact=p=0:nk=1 -safe 0 $extra_args $(target_path $concatfile)
655 venc_data(){
656 file=$1
657 stream=$2
658 frames=$3
659 run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
662 null(){
666 # Disable globbing: command arguments may contain globbing characters and
667 # must be kept verbatim
668 set -f
670 exec 3>&2
671 eval $command >"$outfile" 2>$errfile
672 err=$?
674 if [ $err -gt 128 ]; then
675 sig=$(kill -l $err 2>/dev/null)
676 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
679 if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
680 case $cmp in
681 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
682 rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
683 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
684 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
685 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
686 grep) grep "$ref" "$errfile" >$cmpfile ;;
687 null) cat "$outfile" >$cmpfile ;;
688 esac
689 cmperr=$?
690 test $err = 0 && err=$cmperr
691 if [ "$report_type" = "ignore" ]; then
692 test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
693 else
694 test $err = 0 || cat $cmpfile
696 else
697 echo "reference file '$ref' not found"
698 err=1
701 if [ $err -eq 0 ] && test $report_type = "standard" ; then
702 unset cmpo erro
703 else
704 echo "threads=$threads" >> "$errfile"
705 cmpo="$($base64 <$cmpfile)"
706 erro="$($base64 <$errfile)"
708 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
710 if test $err != 0 && test $gen != "no" && test "${ref#tests/data/}" = "$ref" ; then
711 echo "GEN $ref"
712 cp -f "$outfile" "$ref"
713 err=$?
716 if test $err = 0; then
717 if test $keep -lt 2; then
718 rm -f $outfile $errfile $cmpfile $cleanfiles
720 elif test $gen = "no"; then
721 echo "Test $test failed. Look at $errfile for details."
722 test "${V:-0}" -gt 0 && cat $errfile
723 else
724 echo "Updating reference failed, possibly no output file was generated."
726 exit $err