2010-03-15 21:23:24 +02:00
#! /bin/sh
2010-08-23 20:34:08 +03:00
export LC_ALL = C
2010-03-15 21:23:24 +02:00
base = $( dirname $0 )
. " ${ base } /md5.sh "
2019-04-19 18:04:33 +02:00
base64 = tests/base64${ HOSTEXECSUF }
2010-07-27 02:44:06 +03:00
2010-03-15 21:23:24 +02:00
test = " ${ 1 #fate- } "
2014-03-18 03:29:50 +03:00
target_samples = $2
2010-03-15 21:23:24 +02:00
target_exec = $3
2010-07-18 23:19:16 +03:00
target_path = $4
2010-03-15 21:23:24 +02:00
command = $5
2010-07-09 03:40:45 +03:00
cmp = ${ 6 :- diff }
ref = ${ 7 :- " ${ base } /ref/fate/ ${ test } " }
2012-03-11 02:50:45 +03:00
fuzz = ${ 8 :- 1 }
2011-03-22 01:07:54 +02:00
threads = ${ 9 :- 1 }
2011-09-04 11:01:59 +03:00
thread_type = ${ 10 :- frame +slice }
2012-03-05 10:05:56 +03:00
cpuflags = ${ 11 :- all }
2012-03-11 02:53:19 +03:00
cmp_shift = ${ 12 :- 0 }
2012-03-11 03:33:34 +03:00
cmp_target = ${ 13 :- 0 }
2012-03-11 03:52:05 +03:00
size_tolerance = ${ 14 :- 0 }
2012-05-17 21:14:17 +03:00
cmp_unit = ${ 15 :- 2 }
2013-03-19 01:45:58 +03:00
gen = ${ 16 :- no }
2015-03-09 11:56:54 +02:00
hwaccel = ${ 17 :- none }
2016-12-28 00:19:49 +02:00
report_type = ${ 18 :- standard }
2018-07-06 11:23:33 +02:00
keep = ${ 19 :- 0 }
2010-07-17 18:02:32 +03:00
2010-03-15 21:23:24 +02:00
outdir = "tests/data/fate"
outfile = " ${ outdir } / ${ test } "
2010-07-21 23:49:34 +03:00
errfile = " ${ outdir } / ${ test } .err "
2010-07-27 02:44:06 +03:00
cmpfile = " ${ outdir } / ${ test } .diff "
repfile = " ${ outdir } / ${ test } .rep "
2010-03-15 21:23:24 +02:00
2023-06-22 18:42:24 +02:00
case $threads in
random*)
threads_max = ${ threads #random }
[ -z " $threads_max " ] && threads_max = 16
2023-09-19 15:28:49 +02:00
threads = $( awk " BEGIN { srand(); print 1+int(rand() * $threads_max ) } " < /dev/null)
2023-06-22 18:42:24 +02:00
; ;
esac
2012-04-17 18:47:57 +03:00
target_path( ) {
test ${ 1 } = ${ 1 #/ } && p = ${ target_path } /
echo ${ p } ${ 1 }
}
2012-03-11 03:33:34 +03:00
# $1=value1, $2=value2, $3=threshold
# prints 0 if absolute difference between value1 and value2 is <= threshold
compare( ) {
2015-01-19 23:56:59 +02:00
awk " BEGIN { v = $1 - $2 ; printf ((v < 0 ? -v : v) > $3 ) } "
2012-03-11 03:33:34 +03:00
}
2010-07-17 18:02:34 +03:00
do_tiny_psnr( ) {
2019-04-19 18:04:33 +02:00
psnr = $( tests/tiny_psnr${ HOSTEXECSUF } " $1 " " $2 " $cmp_unit $cmp_shift 0) || return 1
2010-07-17 18:02:34 +03:00
val = $( expr " $psnr " : " .* $3 : *\([0-9.]*\) " )
2010-07-10 19:58:00 +03:00
size1 = $( expr " $psnr " : '.*bytes: *\([0-9]*\)' )
size2 = $( expr " $psnr " : '.*bytes:[ 0-9]*/ *\([0-9]*\)' )
2012-03-11 03:33:34 +03:00
val_cmp = $( compare $val $cmp_target $fuzz )
2012-03-11 03:52:05 +03:00
size_cmp = $( compare $size1 $size2 $size_tolerance )
if [ " $val_cmp " != 0 ] || [ " $size_cmp " != 0 ] ; then
2010-07-09 03:40:51 +03:00
echo " $psnr "
2015-03-08 08:53:22 +02:00
if [ " $val_cmp " != 0 ] ; then
echo " $3 : | $val - $cmp_target | >= $fuzz "
fi
if [ " $size_cmp " != 0 ] ; then
echo " size: | $size1 - $size2 | >= $size_tolerance "
fi
2010-07-09 03:40:51 +03:00
return 1
fi
}
2010-07-17 18:02:34 +03:00
oneoff( ) {
2012-03-11 03:33:34 +03:00
do_tiny_psnr " $1 " " $2 " MAXDIFF
2010-07-17 18:02:34 +03:00
}
stddev( ) {
2012-03-11 03:33:34 +03:00
do_tiny_psnr " $1 " " $2 " stddev
2010-07-17 18:02:34 +03:00
}
2012-05-04 01:43:11 +03:00
oneline( ) {
2012-05-15 13:52:28 +03:00
printf '%s\n' " $1 " | diff -u -b - " $2 "
2012-05-04 01:43:11 +03:00
}
2010-08-04 09:56:59 +03:00
run( ) {
2010-09-23 12:55:31 +03:00
test " ${ V :- 0 } " -gt 0 && echo " $target_exec " $target_path /" $@ " >& 3
2010-08-04 09:56:59 +03:00
$target_exec $target_path /" $@ "
}
2014-05-13 19:16:44 +03:00
runecho( ) {
test " ${ V :- 0 } " -gt 0 && echo " $target_exec " $target_path /" $@ " >& 3
$target_exec $target_path /" $@ " >& 3
}
2012-05-03 21:01:00 +03:00
probefmt( ) {
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_entries format = format_name -print_format default = nw = 1:nk= 1 " $@ "
2013-08-20 16:53:42 +03:00
}
2020-06-15 14:37:41 +02:00
probeaudiostream( ) {
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_entries stream = codec_name,codec_time_base,sample_fmt,channels,channel_layout:side_data " $@ "
2020-06-15 14:37:41 +02:00
}
2018-01-28 04:21:28 +02:00
probetags( ) {
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_entries format_tags " $@ "
2018-01-28 04:21:28 +02:00
}
2015-09-27 14:06:54 +02:00
runlocal( ) {
test " ${ V :- 0 } " -gt 0 && echo ${ base } /" $@ " ${ base } >& 3
${ base } /" $@ " ${ base }
}
2013-08-20 16:53:42 +03:00
probeframes( ) {
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_frames " $@ "
2012-05-03 21:01:00 +03:00
}
2016-04-15 02:30:12 +02:00
probechapters( ) {
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_chapters " $@ "
2016-04-15 02:30:12 +02:00
}
2016-03-07 23:57:51 +02:00
probegaplessinfo( ) {
filename = " $1 "
shift
2020-08-21 13:03:50 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -select_streams a -show_entries format = start_time,duration:stream= index,start_pts,duration_ts " $filename " " $@ "
2016-03-07 23:57:51 +02:00
pktfile1 = " ${ outdir } / ${ test } .pkts "
framefile1 = " ${ outdir } / ${ test } .frames "
cleanfiles = " $cleanfiles $pktfile1 $framefile1 "
2020-08-21 13:03:50 +02:00
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 "
2016-03-07 23:57:51 +02:00
head -n 8 " $pktfile1 "
tail -n 9 " $pktfile1 "
2021-07-14 17:48:10 +02:00
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 "
2016-03-07 23:57:51 +02:00
head -n 8 " $framefile1 "
tail -n 9 " $framefile1 "
}
2012-05-27 16:34:47 +03:00
ffmpeg( ) {
2015-03-09 11:56:54 +02:00
dec_opts = " -hwaccel $hwaccel -threads $threads -thread_type $thread_type "
2020-08-14 18:58:27 +02:00
ffmpeg_args = " -nostdin -nostats -noauto_conversion_filters -cpuflags $cpuflags "
2012-05-29 12:41:55 +03:00
for arg in $@ ; do
2012-12-05 19:33:12 +03:00
[ x${ arg } = x-i ] && ffmpeg_args = " ${ ffmpeg_args } ${ dec_opts } "
2012-07-09 23:10:38 +03:00
ffmpeg_args = " ${ ffmpeg_args } ${ arg } "
2012-05-29 12:41:55 +03:00
done
2019-04-02 13:13:06 +02:00
run ffmpeg${ PROGSUF } ${ EXECSUF } ${ ffmpeg_args }
2010-07-18 23:19:30 +03:00
}
2021-04-24 16:05:31 +02:00
ffprobe_demux( ) {
filename = $1
shift
print_filename = $( basename " $filename " )
run ffprobe${ PROGSUF } ${ EXECSUF } -print_filename " ${ print_filename } " \
-of compact -bitexact -show_format -show_streams -show_packets \
-show_data_hash CRC32 " $filename " " $@ "
}
2010-07-18 23:19:30 +03:00
framecrc( ) {
2017-10-22 01:19:59 +02:00
ffmpeg " $@ " -bitexact -f framecrc -
2010-07-18 23:19:30 +03:00
}
2016-11-08 13:27:21 +02:00
ffmetadata( ) {
2017-10-22 01:19:59 +02:00
ffmpeg " $@ " -bitexact -f ffmetadata -
2016-11-08 13:27:21 +02:00
}
2010-07-18 23:19:30 +03:00
framemd5( ) {
2017-10-22 01:19:59 +02:00
ffmpeg " $@ " -bitexact -f framemd5 -
2010-07-18 23:19:30 +03:00
}
crc( ) {
2015-10-17 12:25:48 +02:00
ffmpeg " $@ " -f crc -
2010-07-18 23:19:30 +03:00
}
2017-06-16 22:08:02 +02:00
md5pipe( ) {
2015-10-17 12:25:48 +02:00
ffmpeg " $@ " md5:
2010-07-18 23:19:30 +03:00
}
2017-06-16 22:08:02 +02:00
md5( ) {
encfile = " ${ outdir } / ${ test } .out "
cleanfiles = " $cleanfiles $encfile "
2020-12-05 00:42:55 +02:00
ffmpeg -y " $@ " $( target_path $encfile ) || return
2017-06-16 22:08:02 +02:00
do_md5sum $encfile | awk '{print $1}'
}
2010-07-18 23:19:30 +03:00
pcm( ) {
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters " $@ " -vn -f s16le -
2010-07-18 23:19:30 +03:00
}
2014-10-11 14:55:55 +03:00
fmtstdout( ) {
fmt = $1
shift 1
2021-10-01 20:33:33 +02:00
ffmpeg -bitexact " $@ " -bitexact -f $fmt -
2014-10-11 14:55:55 +03:00
}
2012-03-11 00:37:41 +03:00
enc_dec_pcm( ) {
out_fmt = $1
2012-04-17 18:47:57 +03:00
dec_fmt = $2
pcm_fmt = $3
src_file = $( target_path $4 )
shift 4
2012-03-11 00:37:41 +03:00
encfile = " ${ outdir } / ${ test } . ${ out_fmt } "
cleanfiles = $encfile
2012-04-17 18:47:57 +03:00
encfile = $( target_path ${ encfile } )
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters -i $src_file " $@ " -f $out_fmt -y ${ encfile } || return
ffmpeg -auto_conversion_filters -bitexact -i ${ encfile } -c:a pcm_${ pcm_fmt } -fflags +bitexact -f ${ dec_fmt } -
2012-03-11 00:37:41 +03:00
}
2014-05-01 11:43:10 +03:00
FLAGS = "-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
2022-05-06 09:54:24 +02:00
DEC_OPTS = " -threads $threads -thread_type $thread_type -idct simple $FLAGS "
2012-05-18 12:33:28 +03:00
ENC_OPTS = "-threads 1 -idct simple -dct fastint"
enc_dec( ) {
2022-05-20 10:37:26 +02:00
enc_fmt_in = $1
2012-05-18 12:33:28 +03:00
srcfile = $2
2022-05-20 10:37:26 +02:00
enc_fmt_out = $3
enc_opt_out = $4
dec_fmt_out = $5
dec_opt_out = $6
dec_opt_in = $7
2022-05-04 12:04:21 +02:00
ffprobe_opts = $8
2022-05-20 11:33:03 +02:00
twopass = $9
2022-05-20 10:37:26 +02:00
encfile = " ${ outdir } / ${ test } . ${ enc_fmt_out } "
decfile = " ${ outdir } / ${ test } .out. ${ dec_fmt_out } "
2012-05-18 12:33:28 +03:00
cleanfiles = " $cleanfiles $decfile "
2022-05-04 12:04:21 +02:00
test " $keep " -ge 1 || cleanfiles = " $cleanfiles $encfile "
2012-05-18 12:33:28 +03:00
tsrcfile = $( target_path $srcfile )
tencfile = $( target_path $encfile )
tdecfile = $( target_path $decfile )
2022-05-20 11:33:03 +02:00
if [ -n " $twopass " ] ; then
logfile_prefix = " ${ outdir } / ${ test } .pass1 "
cleanfiles = " $cleanfiles ${ logfile_prefix } -0.log "
tlogfile_prefix = $( target_path $logfile_prefix )
ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile \
$ENC_OPTS $enc_opt_out $FLAGS -pass 1 -passlogfile $tlogfile_prefix \
-f $enc_fmt_out -y $tencfile || return
enc_opt_out = " $enc_opt_out -pass 2 -passlogfile $tlogfile_prefix "
fi
2022-05-20 10:37:26 +02:00
ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt_out $FLAGS \
-f $enc_fmt_out -y $tencfile || return
2012-05-18 12:33:28 +03:00
do_md5sum $encfile
echo $( wc -c $encfile )
2022-05-20 10:37:26 +02:00
ffmpeg -auto_conversion_filters $dec_opt_in $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt_out $FLAGS \
-f $dec_fmt_out -y $tdecfile || return
2012-05-18 12:33:28 +03:00
do_md5sum $decfile
2019-04-19 18:04:33 +02:00
tests/tiny_psnr${ HOSTEXECSUF } $srcfile $decfile $cmp_unit $cmp_shift
2020-04-13 04:09:21 +02:00
test -z $ffprobe_opts || \
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact $ffprobe_opts $tencfile || return
2012-05-18 12:33:28 +03:00
}
2016-09-05 18:46:16 +02:00
transcode( ) {
src_fmt = $1
srcfile = $2
enc_fmt = $3
enc_opt = $4
2022-05-03 11:09:22 +02:00
final_encode = $5
2022-05-04 12:04:21 +02:00
ffprobe_opts = $6
additional_input = $7
final_decode = $8
2022-09-07 22:36:45 +02:00
enc_opt_in = $9
2021-10-08 09:39:10 +02:00
test -z " $additional_input " || additional_input = " $DEC_OPTS $additional_input "
2016-09-05 18:46:16 +02:00
encfile = " ${ outdir } / ${ test } . ${ enc_fmt } "
2022-05-04 12:04:21 +02:00
test $keep -ge 1 || cleanfiles = " $cleanfiles $encfile "
2016-09-05 18:46:16 +02:00
tsrcfile = $( target_path $srcfile )
tencfile = $( target_path $encfile )
2022-09-07 22:36:45 +02:00
ffmpeg -f $src_fmt $DEC_OPTS $enc_opt_in -i $tsrcfile $additional_input \
2021-08-29 07:38:32 +02:00
$ENC_OPTS $enc_opt $FLAGS -f $enc_fmt -y $tencfile || return
2016-09-05 18:46:16 +02:00
do_md5sum $encfile
echo $( wc -c $encfile )
2022-05-03 11:09:22 +02:00
ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode \
2016-09-09 23:17:02 +02:00
-f framecrc - || return
2020-04-13 04:09:21 +02:00
test -z $ffprobe_opts || \
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact $ffprobe_opts $tencfile || return
2016-09-05 18:46:16 +02:00
}
2018-02-15 14:18:47 +02:00
stream_remux( ) {
src_fmt = $1
srcfile = $2
2023-09-07 04:01:04 +02:00
src_opts = $3
enc_fmt = $4
stream_maps = $5
final_decode = $6
ffprobe_opts = $7
2018-02-15 14:18:47 +02:00
encfile = " ${ outdir } / ${ test } . ${ enc_fmt } "
2022-05-04 12:04:21 +02:00
test $keep -ge 1 || cleanfiles = " $cleanfiles $encfile "
2018-02-15 14:18:47 +02:00
tsrcfile = $( target_path $srcfile )
tencfile = $( target_path $encfile )
2023-09-07 04:01:04 +02:00
ffmpeg -f $src_fmt $src_opts -i $tsrcfile $stream_maps -codec copy $FLAGS \
2018-02-15 14:18:47 +02:00
-f $enc_fmt -y $tencfile || return
2019-12-11 22:52:59 +02:00
ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
2018-02-15 14:18:47 +02:00
-f framecrc - || return
2020-04-13 04:09:21 +02:00
test -z $ffprobe_opts || \
2022-04-30 02:53:32 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact $ffprobe_opts $tencfile || return
2018-02-15 14:18:47 +02:00
}
2023-03-11 18:54:46 +02:00
# this function is for testing external encoders,
# where the precise output is not controlled by us
# we can still test e.g. that the output can be decoded correctly
enc_external( ) {
srcfile = $1
enc_fmt = $2
enc_opt = $3
probe_opt = $4
srcfile = $( target_path $srcfile )
encfile = $( target_path " ${ outdir } / ${ test } . ${ enc_fmt } " )
ffmpeg -i $srcfile $enc_opt -f $enc_fmt -y $encfile || return
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact $probe_opt $encfile || return
}
2018-08-08 22:17:49 +02:00
# FIXME: There is a certain duplication between the avconv-related helper
# functions above and below that should be refactored.
2019-04-02 13:13:06 +02:00
ffmpeg2 = " $target_exec ${ target_path } /ffmpeg ${ PROGSUF } ${ EXECSUF } "
2018-08-08 22:17:49 +02:00
raw_src = " ${ target_path } /tests/vsynth1/%02d.pgm "
2019-02-02 14:49:53 +02:00
pcm_src = " ${ target_path } /tests/data/asynth1.sw "
2018-08-08 22:17:49 +02:00
2019-03-14 19:04:55 +02:00
[ " ${ V -0 } " -gt 0 ] && echov = echov || echov = :
2018-08-08 22:17:49 +02:00
echov( ) {
echo " $@ " >& 3
}
2021-08-08 11:45:07 +02:00
AVCONV_OPTS = " -nostdin -nostats -noauto_conversion_filters -y -cpuflags $cpuflags -filter_threads $threads "
2019-03-19 06:04:49 +02:00
COMMON_OPTS = "-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
DEC_OPTS = " $COMMON_OPTS -threads $threads "
ENC_OPTS = " $COMMON_OPTS -threads 1 -dct fastint "
2018-08-08 22:17:49 +02:00
run_avconv( ) {
2019-03-14 19:04:55 +02:00
$echov $ffmpeg2 $AVCONV_OPTS $*
$ffmpeg2 $AVCONV_OPTS $*
2018-08-08 22:17:49 +02:00
}
do_avconv( ) {
f = " $1 "
shift
set -- $* ${ target_path } /$f
run_avconv $*
do_md5sum $f
echo $( wc -c $f )
}
do_avconv_crc( ) {
f = " $1 "
shift
2022-05-03 05:15:06 +02:00
printf "%s " " $f "
run_avconv $* -f crc -
2018-08-08 22:17:49 +02:00
}
2019-02-02 14:49:53 +02:00
lavf_audio( ) {
t = " ${ test #lavf- } "
outdir = "tests/data/lavf"
file = ${ outdir } /lavf.$t
2022-05-04 15:49:40 +02:00
test " $keep " -ge 1 || cleanfiles = " $cleanfiles $file "
2020-08-14 18:58:27 +02:00
do_avconv $file -auto_conversion_filters $DEC_OPTS $1 -ar 44100 -f s16le -i $pcm_src " $ENC_OPTS -metadata title=lavftest " -t 1 -qscale 10 $2
2022-05-03 05:09:06 +02:00
test " $4 " = "disable_crc" ||
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $3 -i $target_path /$file
2019-02-02 14:49:53 +02:00
}
2019-02-02 14:58:08 +02:00
lavf_container( ) {
t = " ${ test #lavf- } "
outdir = "tests/data/lavf"
file = ${ outdir } /lavf.$t
2022-05-04 15:49:40 +02:00
test " $keep " -ge 1 || cleanfiles = " $cleanfiles $file "
2020-08-14 18:58:27 +02:00
do_avconv $file -auto_conversion_filters $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
2019-08-28 17:32:37 +02:00
test " $3 " = "disable_crc" ||
2020-08-14 18:58:27 +02:00
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path /$file $3
2019-02-02 14:58:08 +02:00
}
2019-03-14 19:36:24 +02:00
lavf_container_attach( ) { lavf_container "" " $1 -attach ${ raw_src %/* } /00.pgm -metadata:s:t mimetype=image/x-portable-greymap " ; }
lavf_container_timecode_nodrop( ) { lavf_container "" " $1 -timecode 02:56:14:13 " ; }
lavf_container_timecode_drop( ) { lavf_container "" " $1 -timecode 02:56:14.13 -r 30000/1001 " ; }
lavf_container_timecode( )
{
lavf_container_timecode_nodrop " $@ "
lavf_container_timecode_drop " $@ "
lavf_container "" " $1 "
}
2019-03-14 19:37:44 +02:00
lavf_container_fate( )
{
t = " ${ test #lavf-fate- } "
outdir = "tests/data/lavf-fate"
file = ${ outdir } /lavf.$t
2022-04-22 23:47:38 +02:00
cleanfiles = " $cleanfiles $file "
2019-03-14 19:37:44 +02:00
input = " ${ target_samples } / $1 "
2020-08-14 18:58:27 +02:00
do_avconv $file -auto_conversion_filters $DEC_OPTS $2 -i " $input " " $ENC_OPTS -metadata title=lavftest " -vcodec copy -acodec copy
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path /$file $3
2019-03-14 19:37:44 +02:00
}
2019-02-02 14:54:47 +02:00
lavf_image( ) {
2022-08-01 14:24:51 +02:00
no_file_checksums = " $3 "
2022-05-04 15:49:40 +02:00
nb_frames = 13
2019-02-02 14:54:47 +02:00
t = " ${ test #lavf- } "
outdir = " tests/data/images/ $t "
mkdir -p " $outdir "
file = ${ outdir } /%02d.$t
2022-05-04 15:49:40 +02:00
if [ " $keep " -lt 1 ] ; then
for i in ` seq $nb_frames ` ; do
filename = ` printf " $file " $i `
cleanfiles = " $cleanfiles $filename "
done
fi
run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 " $ENC_OPTS -metadata title=lavftest " -vf scale -frames $nb_frames -y -qscale 10 $target_path /$file
2022-08-01 14:24:51 +02:00
if [ -z " $no_file_checksums " ] ; then
do_md5sum ${ outdir } /02.$t
echo $( wc -c ${ outdir } /02.$t )
fi
2020-08-14 18:58:27 +02:00
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $2 -i $target_path /$file $2
2019-02-02 14:54:47 +02:00
}
2018-08-08 22:17:49 +02:00
lavf_image2pipe( ) {
t = " ${ test #lavf- } "
t = " ${ t %pipe } "
outdir = "tests/data/lavf"
file = ${ outdir } /${ t } pipe.$t
2020-08-14 18:58:27 +02:00
do_avconv $file -auto_conversion_filters $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src -f image2pipe " $ENC_OPTS -metadata title=lavftest " -t 1 -qscale 10
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -f image2pipe -i $target_path /$file
2018-08-08 22:17:49 +02:00
}
2018-08-08 22:06:38 +02:00
lavf_video( ) {
2013-05-06 19:35:34 +03:00
t = " ${ test #lavf- } "
2018-08-08 22:06:38 +02:00
outdir = "tests/data/lavf"
file = ${ outdir } /lavf.$t
2022-05-04 15:49:40 +02:00
test " $keep " -ge 1 || cleanfiles = " $cleanfiles $file "
2020-08-14 18:58:27 +02:00
do_avconv $file -auto_conversion_filters $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src " $ENC_OPTS -metadata title=lavftest " -t 1 -qscale 10 $1 $2
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path /$file $1
2010-07-20 13:19:28 +03:00
}
2017-08-29 14:45:13 +02:00
refcmp_metadata( ) {
refcmp = $1
pixfmt = $2
fuzz = ${ 3 :- 0 .001 }
2022-03-30 00:55:14 +02:00
ffmpeg -auto_conversion_filters $FLAGS $ENC_OPTS \
2017-08-29 14:45:13 +02:00
-lavfi " testsrc2=size=300x200:rate=1:duration=5,format= ${ pixfmt } ,split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref] ${ refcmp } ,metadata=print:file=- " \
-f null /dev/null | awk -v ref = ${ ref } -v fuzz = ${ fuzz } -f ${ base } /refcmp-metadata.awk -
}
2022-03-22 10:34:02 +02:00
cmp_metadata( ) {
refcmp = $1
pixfmt = $2
fuzz = ${ 3 :- 0 .001 }
ffmpeg $FLAGS $ENC_OPTS \
-lavfi " testsrc2=size=300x200:rate=1:duration=5,format= ${ pixfmt } , ${ refcmp } ,metadata=print:file=- " \
-f null /dev/null | awk -v ref = ${ ref } -v fuzz = ${ fuzz } -f ${ base } /refcmp-metadata.awk -
}
2022-03-24 00:55:21 +02:00
refcmp_metadata_files( ) {
2022-04-28 21:37:26 +02:00
file1 = $1
file2 = $2
refcmp = $3
pixfmt = $4
2022-03-24 00:55:21 +02:00
fuzz = ${ 5 :- 0 .001 }
ffmpeg -auto_conversion_filters $FLAGS -i $file1 $FLAGS -i $file2 $ENC_OPTS \
-lavfi " [0:v]format= ${ pixfmt } [v0];[1:v]format= ${ pixfmt } [v1];[v0][v1] ${ refcmp } ,metadata=print:file=- " \
-f null /dev/null | awk -v ref = ${ ref } -v fuzz = ${ fuzz } -f ${ base } /refcmp-metadata.awk -
}
2022-04-28 21:37:26 +02:00
refcmp_metadata_transcode( ) {
srcfile = $1
enc_opt = $2
enc_fmt = $3
enc_ext = $4
shift 4
encfile = " ${ outdir } / ${ test } . ${ enc_ext } "
cleanfiles = " $cleanfiles $encfile "
tsrcfile = $( target_path $srcfile )
tencfile = $( target_path $encfile )
ffmpeg $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS -y -f $enc_fmt $tencfile || return
refcmp_metadata_files $tencfile $tsrcfile " $@ "
}
2018-08-14 11:07:10 +02:00
pixfmt_conversion( ) {
conversion = " ${ test #pixfmt- } "
outdir = "tests/data/pixfmt"
raw_dst = " $outdir / $conversion .out.yuv "
file = ${ outdir } /${ conversion } .yuv
2022-05-04 16:16:06 +02:00
cleanfiles = " $cleanfiles $raw_dst $file "
2018-08-14 11:07:10 +02:00
run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
$ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path /$raw_dst
do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path /$raw_dst \
$ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
}
2013-04-16 00:39:08 +03:00
video_filter( ) {
filters = $1
shift
label = ${ test #filter- }
raw_src = " ${ target_path } /tests/vsynth1/%02d.pgm "
printf '%-20s' $label
2015-10-17 12:25:48 +02:00
ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
2015-05-09 23:44:30 +02:00
$FLAGS $ENC_OPTS -vf " $filters " -vcodec rawvideo -frames:v 5 $* -f nut md5:
2013-04-16 00:39:08 +03:00
}
2013-04-16 02:42:38 +03:00
pixfmts( ) {
filter = ${ test #filter-pixfmts- }
2013-04-30 03:08:48 +03:00
filter = ${ filter %_* }
2013-04-16 02:42:38 +03:00
filter_args = $1
2013-04-30 02:45:08 +03:00
prefilter_chain = $2
2015-05-11 00:44:14 +02:00
nframes = ${ 3 :- 1 }
2013-04-16 02:42:38 +03:00
2019-04-18 03:24:35 +02:00
showfiltfmts = " $target_exec $target_path /libavfilter/tests/filtfmts ${ EXECSUF } "
2013-05-01 14:13:49 +03:00
scale_exclude_fmts = ${ outfile } _scale_exclude_fmts
scale_in_fmts = ${ outfile } _scale_in_fmts
scale_out_fmts = ${ outfile } _scale_out_fmts
in_fmts = ${ outfile } _in_fmts
2013-04-16 02:42:38 +03:00
# exclude pixel formats which are not supported as input
2013-04-30 02:32:49 +03:00
$showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
$showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
$showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
pix_fmts = $( comm -12 $scale_exclude_fmts $in_fmts )
2013-04-16 02:42:38 +03:00
2014-11-10 07:37:18 +02:00
outertest = $test
2013-04-16 02:42:38 +03:00
for pix_fmt in $pix_fmts ; do
test = $pix_fmt
2020-08-14 18:58:27 +02:00
video_filter " ${ prefilter_chain } scale,format= $pix_fmt , $filter = $filter_args " -pix_fmt $pix_fmt -frames:v $nframes
2013-04-16 02:42:38 +03:00
done
2013-04-30 02:32:49 +03:00
rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
2014-11-10 07:37:18 +02:00
test = $outertest
2013-04-16 02:42:38 +03:00
}
2015-04-15 21:10:49 +02:00
gapless( ) {
sample = $( target_path $1 )
extra_args = $2
decfile1 = " ${ outdir } / ${ test } .out-1 "
decfile2 = " ${ outdir } / ${ test } .out-2 "
2015-04-17 17:27:02 +02:00
decfile3 = " ${ outdir } / ${ test } .out-3 "
cleanfiles = " $cleanfiles $decfile1 $decfile2 $decfile3 "
2015-04-15 21:10:49 +02:00
# test packet data
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters $extra_args -i " $sample " -bitexact -c:a copy -f framecrc -y $( target_path $decfile1 )
2015-04-15 21:10:49 +02:00
do_md5sum $decfile1
# test decoded (and cut) data
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters $extra_args -i " $sample " -bitexact -f wav md5:
2015-04-17 17:27:01 +02:00
# the same as above again, with seeking to the start
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i " $sample " -bitexact -c:a copy -f framecrc -y $( target_path $decfile2 )
2015-04-15 21:10:49 +02:00
do_md5sum $decfile2
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i " $sample " -bitexact -f wav md5:
2015-04-17 17:27:02 +02:00
# test packet data, with seeking to a specific position
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters $extra_args -ss 5 -seek_timestamp 1 -i " $sample " -bitexact -c:a copy -f framecrc -y $( target_path $decfile3 )
2015-04-17 17:27:02 +02:00
do_md5sum $decfile3
2015-04-15 21:10:49 +02:00
}
2016-03-07 23:57:51 +02:00
gaplessenc( ) {
sample = $( target_path $1 )
format = $2
codec = $3
file1 = " ${ outdir } / ${ test } .out-1 "
cleanfiles = " $cleanfiles $file1 "
# test data after reencoding
2020-08-14 18:58:27 +02:00
ffmpeg -i " $sample " -bitexact -map 0:a -c:a $codec -af aresample -f $format -y " $( target_path " $file1 " ) "
2019-12-11 22:52:59 +02:00
probegaplessinfo " $( target_path " $file1 " ) "
2016-03-07 23:57:51 +02:00
}
2016-03-21 05:18:48 +02:00
audio_match( ) {
sample = $( target_path $1 )
2019-12-11 22:52:59 +02:00
trefile = $2
2016-03-21 05:18:48 +02:00
extra_args = $3
decfile = " ${ outdir } / ${ test } .wav "
cleanfiles = " $cleanfiles $decfile "
2020-08-14 18:58:27 +02:00
ffmpeg -auto_conversion_filters -i " $sample " -bitexact $extra_args -y $( target_path $decfile )
2019-04-19 18:04:33 +02:00
tests/audiomatch${ HOSTEXECSUF } $decfile $trefile
2016-03-21 05:18:48 +02:00
}
2015-10-24 15:39:18 +02:00
concat( ) {
template = $1
2015-11-16 02:25:18 +02:00
sample = $2
2015-10-24 15:39:18 +02:00
mode = $3
extra_args = $4
concatfile = " ${ outdir } / ${ test } .ffconcat "
packetfile = " ${ outdir } / ${ test } .ffprobe "
cleanfiles = " $concatfile $packetfile "
awk " {gsub(/%SRCFILE%/, \" $sample \"); print} " $template > $concatfile
if [ " $mode " = "md5" ] ; then
2020-08-21 13:03:50 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_streams -show_packets -safe 0 $extra_args $( target_path $concatfile ) | tr -d '\r' > $packetfile
2015-11-26 07:03:14 +02:00
do_md5sum $packetfile
2015-10-24 15:39:18 +02:00
else
2020-08-21 13:03:50 +02:00
run ffprobe${ PROGSUF } ${ EXECSUF } -bitexact -show_streams -show_packets -of compact = p = 0:nk= 1 -safe 0 $extra_args $( target_path $concatfile )
2015-10-24 15:39:18 +02:00
fi
2017-10-12 00:35:56 +02:00
}
2017-10-12 00:02:04 +02:00
2020-05-11 17:06:11 +02:00
venc_data( ) {
file = $1
stream = $2
frames = $3
run tools/venc_data_dump${ EXECSUF } ${ file } ${ stream } ${ frames } ${ threads } ${ thread_type }
}
2012-10-05 15:46:38 +03:00
null( ) {
:
2015-10-24 15:39:18 +02:00
}
2013-01-03 01:22:46 +03:00
# Disable globbing: command arguments may contain globbing characters and
# must be kept verbatim
set -f
2010-09-23 12:55:31 +03:00
exec 3>& 2
2012-05-18 12:33:28 +03:00
eval $command >" $outfile " 2>$errfile
2010-07-20 15:54:43 +03:00
err = $?
2010-07-09 03:40:45 +03:00
2010-07-31 19:53:09 +03:00
if [ $err -gt 128 ] ; then
sig = $( kill -l $err 2>/dev/null)
2010-08-01 15:29:03 +03:00
test " ${ sig } " = " ${ sig %[!A-Za-z]* } " || unset sig
2010-07-31 19:53:09 +03:00
fi
2017-10-04 03:59:08 +02:00
if test -e " $ref " || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
2010-07-27 02:44:06 +03:00
case $cmp in
2013-09-24 21:53:41 +03:00
diff) diff -u -b " $ref " " $outfile " >$cmpfile ; ;
2014-10-11 20:17:33 +03:00
rawdiff) diff -u " $ref " " $outfile " >$cmpfile ; ;
2012-03-11 02:50:45 +03:00
oneoff) oneoff " $ref " " $outfile " >$cmpfile ; ;
stddev) stddev " $ref " " $outfile " >$cmpfile ; ;
2012-05-04 01:43:11 +03:00
oneline) oneline " $ref " " $outfile " >$cmpfile ; ;
2016-07-14 19:54:34 +02:00
grep) grep " $ref " " $errfile " >$cmpfile ; ;
2011-07-04 02:56:38 +03:00
null) cat " $outfile " >$cmpfile ; ;
2010-07-27 02:44:06 +03:00
esac
cmperr = $?
test $err = 0 && err = $cmperr
2016-12-28 00:19:49 +02:00
if [ " $report_type " = "ignore" ] ; then
2016-12-29 14:20:51 +02:00
test $err = 0 || echo " IGNORE\t ${ test } " && err = 0 && unset sig
2016-12-28 00:19:49 +02:00
else
test $err = 0 || cat $cmpfile
fi
2010-07-27 02:44:06 +03:00
else
2010-07-20 13:19:28 +03:00
echo " reference file ' $ref ' not found "
2010-07-27 02:44:06 +03:00
err = 1
2010-07-20 13:19:28 +03:00
fi
2016-12-28 00:19:49 +02:00
if [ $err -eq 0 ] && test $report_type = "standard" ; then
2015-04-10 19:51:11 +02:00
unset cmpo erro
else
2023-06-22 18:42:24 +02:00
echo " threads= $threads " >> " $errfile "
2015-04-10 19:51:11 +02:00
cmpo = " $( $base64 <$cmpfile ) "
erro = " $( $base64 <$errfile ) "
fi
echo " ${ test } : ${ sig :- $err } : $cmpo : $erro " >$repfile
2010-07-10 02:36:04 +03:00
2013-03-19 01:45:58 +03:00
if test $err != 0 && test $gen != "no" ; then
echo " GEN $ref "
cp -f " $outfile " " $ref "
err = $?
fi
2011-12-22 20:17:13 +03:00
if test $err = 0; then
2022-05-04 12:04:21 +02:00
if test $keep -lt 2; then
2018-07-06 11:23:33 +02:00
rm -f $outfile $errfile $cmpfile $cleanfiles
fi
2013-03-30 13:41:58 +03:00
elif test $gen = "no" ; then
2011-12-22 20:17:13 +03:00
echo " Test $test failed. Look at $errfile for details. "
2014-09-24 00:38:29 +03:00
test " ${ V :- 0 } " -gt 0 && cat $errfile
2013-03-30 13:41:58 +03:00
else
echo "Updating reference failed, possibly no output file was generated."
2011-12-22 20:17:13 +03:00
fi
2010-07-27 02:44:06 +03:00
exit $err