fate-run.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. #! /bin/sh
  2. export LC_ALL=C
  3. base=$(dirname $0)
  4. . "${base}/md5.sh"
  5. base64=tests/base64${HOSTEXECSUF}
  6. test="${1#fate-}"
  7. target_samples=$2
  8. target_exec=$3
  9. target_path=$4
  10. command=$5
  11. cmp=${6:-diff}
  12. ref=${7:-"${base}/ref/fate/${test}"}
  13. fuzz=${8:-1}
  14. threads=${9:-1}
  15. thread_type=${10:-frame+slice}
  16. cpuflags=${11:-all}
  17. cmp_shift=${12:-0}
  18. cmp_target=${13:-0}
  19. size_tolerance=${14:-0}
  20. cmp_unit=${15:-2}
  21. gen=${16:-no}
  22. hwaccel=${17:-none}
  23. report_type=${18:-standard}
  24. keep=${19:-0}
  25. outdir="tests/data/fate"
  26. outfile="${outdir}/${test}"
  27. errfile="${outdir}/${test}.err"
  28. cmpfile="${outdir}/${test}.diff"
  29. repfile="${outdir}/${test}.rep"
  30. target_path(){
  31. test ${1} = ${1#/} && p=${target_path}/
  32. echo ${p}${1}
  33. }
  34. # $1=value1, $2=value2, $3=threshold
  35. # prints 0 if absolute difference between value1 and value2 is <= threshold
  36. compare(){
  37. awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
  38. }
  39. do_tiny_psnr(){
  40. psnr=$(tests/tiny_psnr${HOSTEXECSUF} "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
  41. val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
  42. size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
  43. size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
  44. val_cmp=$(compare $val $cmp_target $fuzz)
  45. size_cmp=$(compare $size1 $size2 $size_tolerance)
  46. if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
  47. echo "$psnr"
  48. if [ "$val_cmp" != 0 ]; then
  49. echo "$3: |$val - $cmp_target| >= $fuzz"
  50. fi
  51. if [ "$size_cmp" != 0 ]; then
  52. echo "size: |$size1 - $size2| >= $size_tolerance"
  53. fi
  54. return 1
  55. fi
  56. }
  57. oneoff(){
  58. do_tiny_psnr "$1" "$2" MAXDIFF
  59. }
  60. stddev(){
  61. do_tiny_psnr "$1" "$2" stddev
  62. }
  63. oneline(){
  64. printf '%s\n' "$1" | diff -u -b - "$2"
  65. }
  66. run(){
  67. test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
  68. $target_exec $target_path/"$@"
  69. }
  70. runecho(){
  71. test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
  72. $target_exec $target_path/"$@" >&3
  73. }
  74. probefmt(){
  75. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries format=format_name -print_format default=nw=1:nk=1 "$@"
  76. }
  77. probeaudiostream(){
  78. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries stream=codec_name,codec_time_base,sample_fmt,channels,channel_layout:side_data "$@"
  79. }
  80. probetags(){
  81. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_entries format_tags "$@"
  82. }
  83. runlocal(){
  84. test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
  85. ${base}/"$@" ${base}
  86. }
  87. probeframes(){
  88. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_frames "$@"
  89. }
  90. probechapters(){
  91. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_chapters "$@"
  92. }
  93. probegaplessinfo(){
  94. filename="$1"
  95. shift
  96. run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts "$filename" "$@"
  97. pktfile1="${outdir}/${test}.pkts"
  98. framefile1="${outdir}/${test}.frames"
  99. cleanfiles="$cleanfiles $pktfile1 $framefile1"
  100. 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"
  101. head -n 8 "$pktfile1"
  102. tail -n 9 "$pktfile1"
  103. 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"
  104. head -n 8 "$framefile1"
  105. tail -n 9 "$framefile1"
  106. }
  107. ffmpeg(){
  108. dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
  109. ffmpeg_args="-nostdin -nostats -noauto_conversion_filters -cpuflags $cpuflags"
  110. for arg in $@; do
  111. [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
  112. ffmpeg_args="${ffmpeg_args} ${arg}"
  113. done
  114. run ffmpeg${PROGSUF}${EXECSUF} ${ffmpeg_args}
  115. }
  116. ffprobe_demux(){
  117. filename=$1
  118. shift
  119. print_filename=$(basename "$filename")
  120. run ffprobe${PROGSUF}${EXECSUF} -print_filename "${print_filename}" \
  121. -of compact -bitexact -show_format -show_streams -show_packets \
  122. -show_data_hash CRC32 "$filename" "$@"
  123. }
  124. framecrc(){
  125. ffmpeg "$@" -bitexact -f framecrc -
  126. }
  127. ffmetadata(){
  128. ffmpeg "$@" -bitexact -f ffmetadata -
  129. }
  130. framemd5(){
  131. ffmpeg "$@" -bitexact -f framemd5 -
  132. }
  133. crc(){
  134. ffmpeg "$@" -f crc -
  135. }
  136. md5pipe(){
  137. ffmpeg "$@" md5:
  138. }
  139. md5(){
  140. encfile="${outdir}/${test}.out"
  141. cleanfiles="$cleanfiles $encfile"
  142. ffmpeg -y "$@" $(target_path $encfile) || return
  143. do_md5sum $encfile | awk '{print $1}'
  144. }
  145. pcm(){
  146. ffmpeg -auto_conversion_filters "$@" -vn -f s16le -
  147. }
  148. fmtstdout(){
  149. fmt=$1
  150. shift 1
  151. ffmpeg -bitexact "$@" -bitexact -f $fmt -
  152. }
  153. enc_dec_pcm(){
  154. out_fmt=$1
  155. dec_fmt=$2
  156. pcm_fmt=$3
  157. src_file=$(target_path $4)
  158. shift 4
  159. encfile="${outdir}/${test}.${out_fmt}"
  160. cleanfiles=$encfile
  161. encfile=$(target_path ${encfile})
  162. ffmpeg -auto_conversion_filters -i $src_file "$@" -f $out_fmt -y ${encfile} || return
  163. ffmpeg -auto_conversion_filters -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
  164. }
  165. FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
  166. DEC_OPTS="-threads $threads -thread_type $thread_type -idct simple $FLAGS"
  167. ENC_OPTS="-threads 1 -idct simple -dct fastint"
  168. enc_dec(){
  169. enc_fmt_in=$1
  170. srcfile=$2
  171. enc_fmt_out=$3
  172. enc_opt_out=$4
  173. dec_fmt_out=$5
  174. dec_opt_out=$6
  175. dec_opt_in=$7
  176. ffprobe_opts=$8
  177. twopass=$9
  178. encfile="${outdir}/${test}.${enc_fmt_out}"
  179. decfile="${outdir}/${test}.out.${dec_fmt_out}"
  180. cleanfiles="$cleanfiles $decfile"
  181. test "$keep" -ge 1 || cleanfiles="$cleanfiles $encfile"
  182. tsrcfile=$(target_path $srcfile)
  183. tencfile=$(target_path $encfile)
  184. tdecfile=$(target_path $decfile)
  185. if [ -n "$twopass" ]; then
  186. logfile_prefix="${outdir}/${test}.pass1"
  187. cleanfiles="$cleanfiles ${logfile_prefix}-0.log"
  188. tlogfile_prefix=$(target_path $logfile_prefix)
  189. ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile \
  190. $ENC_OPTS $enc_opt_out $FLAGS -pass 1 -passlogfile $tlogfile_prefix \
  191. -f $enc_fmt_out -y $tencfile || return
  192. enc_opt_out="$enc_opt_out -pass 2 -passlogfile $tlogfile_prefix"
  193. fi
  194. ffmpeg -auto_conversion_filters -f $enc_fmt_in $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt_out $FLAGS \
  195. -f $enc_fmt_out -y $tencfile || return
  196. do_md5sum $encfile
  197. echo $(wc -c $encfile)
  198. ffmpeg -auto_conversion_filters $dec_opt_in $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt_out $FLAGS \
  199. -f $dec_fmt_out -y $tdecfile || return
  200. do_md5sum $decfile
  201. tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
  202. test -z $ffprobe_opts || \
  203. run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
  204. }
  205. transcode(){
  206. src_fmt=$1
  207. srcfile=$2
  208. enc_fmt=$3
  209. enc_opt=$4
  210. final_encode=$5
  211. ffprobe_opts=$6
  212. additional_input=$7
  213. final_decode=$8
  214. enc_opt_in=$9
  215. test -z "$additional_input" || additional_input="$DEC_OPTS $additional_input"
  216. encfile="${outdir}/${test}.${enc_fmt}"
  217. test $keep -ge 1 || cleanfiles="$cleanfiles $encfile"
  218. tsrcfile=$(target_path $srcfile)
  219. tencfile=$(target_path $encfile)
  220. ffmpeg -f $src_fmt $DEC_OPTS $enc_opt_in -i $tsrcfile $additional_input \
  221. $ENC_OPTS $enc_opt $FLAGS -f $enc_fmt -y $tencfile || return
  222. do_md5sum $encfile
  223. echo $(wc -c $encfile)
  224. ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode \
  225. -f framecrc - || return
  226. test -z $ffprobe_opts || \
  227. run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
  228. }
  229. stream_remux(){
  230. src_fmt=$1
  231. srcfile=$2
  232. enc_fmt=$3
  233. stream_maps=$4
  234. final_decode=$5
  235. ffprobe_opts=$6
  236. encfile="${outdir}/${test}.${enc_fmt}"
  237. test $keep -ge 1 || 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
  244. test -z $ffprobe_opts || \
  245. run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || return
  246. }
  247. # FIXME: There is a certain duplication between the avconv-related helper
  248. # functions above and below that should be refactored.
  249. ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
  250. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  251. pcm_src="${target_path}/tests/data/asynth1.sw"
  252. [ "${V-0}" -gt 0 ] && echov=echov || echov=:
  253. echov(){
  254. echo "$@" >&3
  255. }
  256. AVCONV_OPTS="-nostdin -nostats -noauto_conversion_filters -y -cpuflags $cpuflags -filter_threads $threads"
  257. COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
  258. DEC_OPTS="$COMMON_OPTS -threads $threads"
  259. ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
  260. run_avconv(){
  261. $echov $ffmpeg2 $AVCONV_OPTS $*
  262. $ffmpeg2 $AVCONV_OPTS $*
  263. }
  264. do_avconv(){
  265. f="$1"
  266. shift
  267. set -- $* ${target_path}/$f
  268. run_avconv $*
  269. do_md5sum $f
  270. echo $(wc -c $f)
  271. }
  272. do_avconv_crc(){
  273. f="$1"
  274. shift
  275. printf "%s " "$f"
  276. run_avconv $* -f crc -
  277. }
  278. lavf_audio(){
  279. t="${test#lavf-}"
  280. outdir="tests/data/lavf"
  281. file=${outdir}/lavf.$t
  282. test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
  283. 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
  284. test "$4" = "disable_crc" ||
  285. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $3 -i $target_path/$file
  286. }
  287. lavf_container(){
  288. t="${test#lavf-}"
  289. outdir="tests/data/lavf"
  290. file=${outdir}/lavf.$t
  291. test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
  292. 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
  293. test "$3" = "disable_crc" ||
  294. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $3
  295. }
  296. lavf_container_attach() { lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
  297. lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
  298. lavf_container_timecode_drop() { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }
  299. lavf_container_timecode()
  300. {
  301. lavf_container_timecode_nodrop "$@"
  302. lavf_container_timecode_drop "$@"
  303. lavf_container "" "$1"
  304. }
  305. lavf_container_fate()
  306. {
  307. t="${test#lavf-fate-}"
  308. outdir="tests/data/lavf-fate"
  309. file=${outdir}/lavf.$t
  310. cleanfiles="$cleanfiles $file"
  311. input="${target_samples}/$1"
  312. do_avconv $file -auto_conversion_filters $DEC_OPTS $2 -i "$input" "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy
  313. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $3
  314. }
  315. lavf_image(){
  316. no_file_checksums="$3"
  317. nb_frames=13
  318. t="${test#lavf-}"
  319. outdir="tests/data/images/$t"
  320. mkdir -p "$outdir"
  321. file=${outdir}/%02d.$t
  322. if [ "$keep" -lt 1 ]; then
  323. for i in `seq $nb_frames`; do
  324. filename=`printf "$file" $i`
  325. cleanfiles="$cleanfiles $filename"
  326. done
  327. fi
  328. 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
  329. if [ -z "$no_file_checksums" ]; then
  330. do_md5sum ${outdir}/02.$t
  331. echo $(wc -c ${outdir}/02.$t)
  332. fi
  333. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $2 -i $target_path/$file $2
  334. }
  335. lavf_image2pipe(){
  336. t="${test#lavf-}"
  337. t="${t%pipe}"
  338. outdir="tests/data/lavf"
  339. file=${outdir}/${t}pipe.$t
  340. 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
  341. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -f image2pipe -i $target_path/$file
  342. }
  343. lavf_video(){
  344. t="${test#lavf-}"
  345. outdir="tests/data/lavf"
  346. file=${outdir}/lavf.$t
  347. test "$keep" -ge 1 || cleanfiles="$cleanfiles $file"
  348. 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
  349. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $1
  350. }
  351. refcmp_metadata(){
  352. refcmp=$1
  353. pixfmt=$2
  354. fuzz=${3:-0.001}
  355. ffmpeg -auto_conversion_filters $FLAGS $ENC_OPTS \
  356. -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
  357. -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
  358. }
  359. cmp_metadata(){
  360. refcmp=$1
  361. pixfmt=$2
  362. fuzz=${3:-0.001}
  363. ffmpeg $FLAGS $ENC_OPTS \
  364. -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},${refcmp},metadata=print:file=-" \
  365. -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
  366. }
  367. refcmp_metadata_files(){
  368. file1=$1
  369. file2=$2
  370. refcmp=$3
  371. pixfmt=$4
  372. fuzz=${5:-0.001}
  373. ffmpeg -auto_conversion_filters $FLAGS -i $file1 $FLAGS -i $file2 $ENC_OPTS \
  374. -lavfi "[0:v]format=${pixfmt}[v0];[1:v]format=${pixfmt}[v1];[v0][v1]${refcmp},metadata=print:file=-" \
  375. -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
  376. }
  377. refcmp_metadata_transcode(){
  378. srcfile=$1
  379. enc_opt=$2
  380. enc_fmt=$3
  381. enc_ext=$4
  382. shift 4
  383. encfile="${outdir}/${test}.${enc_ext}"
  384. cleanfiles="$cleanfiles $encfile"
  385. tsrcfile=$(target_path $srcfile)
  386. tencfile=$(target_path $encfile)
  387. ffmpeg $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS -y -f $enc_fmt $tencfile || return
  388. refcmp_metadata_files $tencfile $tsrcfile "$@"
  389. }
  390. pixfmt_conversion(){
  391. conversion="${test#pixfmt-}"
  392. outdir="tests/data/pixfmt"
  393. raw_dst="$outdir/$conversion.out.yuv"
  394. file=${outdir}/${conversion}.yuv
  395. cleanfiles="$cleanfiles $raw_dst $file"
  396. run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
  397. $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst
  398. do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
  399. $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
  400. }
  401. video_filter(){
  402. filters=$1
  403. shift
  404. label=${test#filter-}
  405. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  406. printf '%-20s' $label
  407. ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
  408. $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
  409. }
  410. pixfmts(){
  411. filter=${test#filter-pixfmts-}
  412. filter=${filter%_*}
  413. filter_args=$1
  414. prefilter_chain=$2
  415. nframes=${3:-1}
  416. showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
  417. scale_exclude_fmts=${outfile}_scale_exclude_fmts
  418. scale_in_fmts=${outfile}_scale_in_fmts
  419. scale_out_fmts=${outfile}_scale_out_fmts
  420. in_fmts=${outfile}_in_fmts
  421. # exclude pixel formats which are not supported as input
  422. $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
  423. $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
  424. comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
  425. $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
  426. pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
  427. outertest=$test
  428. for pix_fmt in $pix_fmts; do
  429. test=$pix_fmt
  430. video_filter "${prefilter_chain}scale,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
  431. done
  432. rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
  433. test=$outertest
  434. }
  435. gapless(){
  436. sample=$(target_path $1)
  437. extra_args=$2
  438. decfile1="${outdir}/${test}.out-1"
  439. decfile2="${outdir}/${test}.out-2"
  440. decfile3="${outdir}/${test}.out-3"
  441. cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
  442. # test packet data
  443. ffmpeg -auto_conversion_filters $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile1)
  444. do_md5sum $decfile1
  445. # test decoded (and cut) data
  446. ffmpeg -auto_conversion_filters $extra_args -i "$sample" -bitexact -f wav md5:
  447. # the same as above again, with seeking to the start
  448. ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile2)
  449. do_md5sum $decfile2
  450. ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
  451. # test packet data, with seeking to a specific position
  452. ffmpeg -auto_conversion_filters $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile3)
  453. do_md5sum $decfile3
  454. }
  455. gaplessenc(){
  456. sample=$(target_path $1)
  457. format=$2
  458. codec=$3
  459. file1="${outdir}/${test}.out-1"
  460. cleanfiles="$cleanfiles $file1"
  461. # test data after reencoding
  462. ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -af aresample -f $format -y "$(target_path "$file1")"
  463. probegaplessinfo "$(target_path "$file1")"
  464. }
  465. audio_match(){
  466. sample=$(target_path $1)
  467. trefile=$2
  468. extra_args=$3
  469. decfile="${outdir}/${test}.wav"
  470. cleanfiles="$cleanfiles $decfile"
  471. ffmpeg -auto_conversion_filters -i "$sample" -bitexact $extra_args -y $(target_path $decfile)
  472. tests/audiomatch${HOSTEXECSUF} $decfile $trefile
  473. }
  474. concat(){
  475. template=$1
  476. sample=$2
  477. mode=$3
  478. extra_args=$4
  479. concatfile="${outdir}/${test}.ffconcat"
  480. packetfile="${outdir}/${test}.ffprobe"
  481. cleanfiles="$concatfile $packetfile"
  482. awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
  483. if [ "$mode" = "md5" ]; then
  484. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -safe 0 $extra_args $(target_path $concatfile) | tr -d '\r' > $packetfile
  485. do_md5sum $packetfile
  486. else
  487. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -of compact=p=0:nk=1 -safe 0 $extra_args $(target_path $concatfile)
  488. fi
  489. }
  490. venc_data(){
  491. file=$1
  492. stream=$2
  493. frames=$3
  494. run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
  495. }
  496. null(){
  497. :
  498. }
  499. # Disable globbing: command arguments may contain globbing characters and
  500. # must be kept verbatim
  501. set -f
  502. exec 3>&2
  503. eval $command >"$outfile" 2>$errfile
  504. err=$?
  505. if [ $err -gt 128 ]; then
  506. sig=$(kill -l $err 2>/dev/null)
  507. test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
  508. fi
  509. if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
  510. case $cmp in
  511. diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
  512. rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
  513. oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
  514. stddev) stddev "$ref" "$outfile" >$cmpfile ;;
  515. oneline)oneline "$ref" "$outfile" >$cmpfile ;;
  516. grep) grep "$ref" "$errfile" >$cmpfile ;;
  517. null) cat "$outfile" >$cmpfile ;;
  518. esac
  519. cmperr=$?
  520. test $err = 0 && err=$cmperr
  521. if [ "$report_type" = "ignore" ]; then
  522. test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
  523. else
  524. test $err = 0 || cat $cmpfile
  525. fi
  526. else
  527. echo "reference file '$ref' not found"
  528. err=1
  529. fi
  530. if [ $err -eq 0 ] && test $report_type = "standard" ; then
  531. unset cmpo erro
  532. else
  533. cmpo="$($base64 <$cmpfile)"
  534. erro="$($base64 <$errfile)"
  535. fi
  536. echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
  537. if test $err != 0 && test $gen != "no" ; then
  538. echo "GEN $ref"
  539. cp -f "$outfile" "$ref"
  540. err=$?
  541. fi
  542. if test $err = 0; then
  543. if test $keep -lt 2; then
  544. rm -f $outfile $errfile $cmpfile $cleanfiles
  545. fi
  546. elif test $gen = "no"; then
  547. echo "Test $test failed. Look at $errfile for details."
  548. test "${V:-0}" -gt 0 && cat $errfile
  549. else
  550. echo "Updating reference failed, possibly no output file was generated."
  551. fi
  552. exit $err