fate-run.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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} -show_entries format=format_name -print_format default=nw=1:nk=1 "$@"
  76. }
  77. probeaudiostream(){
  78. run ffprobe${PROGSUF}${EXECSUF} -show_entries stream=codec_name,codec_time_base,sample_fmt,channels,channel_layout:side_data "$@"
  79. }
  80. probetags(){
  81. run ffprobe${PROGSUF}${EXECSUF} -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} -show_frames "$@"
  89. }
  90. probechapters(){
  91. run ffprobe${PROGSUF}${EXECSUF} -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 -idct simple $FLAGS"
  167. ENC_OPTS="-threads 1 -idct simple -dct fastint"
  168. enc_dec(){
  169. src_fmt=$1
  170. srcfile=$2
  171. enc_fmt=$3
  172. enc_opt=$4
  173. dec_fmt=$5
  174. dec_opt=$6
  175. ffprobe_opts=$9
  176. encfile="${outdir}/${test}.${enc_fmt}"
  177. decfile="${outdir}/${test}.out.${dec_fmt}"
  178. cleanfiles="$cleanfiles $decfile"
  179. test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
  180. tsrcfile=$(target_path $srcfile)
  181. tencfile=$(target_path $encfile)
  182. tdecfile=$(target_path $decfile)
  183. ffmpeg -auto_conversion_filters -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
  184. -f $enc_fmt -y $tencfile || return
  185. do_md5sum $encfile
  186. echo $(wc -c $encfile)
  187. ffmpeg -auto_conversion_filters $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
  188. -f $dec_fmt -y $tdecfile || return
  189. do_md5sum $decfile
  190. tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
  191. test -z $ffprobe_opts || \
  192. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts $tencfile || return
  193. }
  194. transcode(){
  195. src_fmt=$1
  196. srcfile=$2
  197. enc_fmt=$3
  198. enc_opt=$4
  199. final_decode=$5
  200. ffprobe_opts=$7
  201. additional_input=$8
  202. test -z "$additional_input" || additional_input="$DEC_OPTS $additional_input"
  203. encfile="${outdir}/${test}.${enc_fmt}"
  204. test "$6" = -keep || cleanfiles="$cleanfiles $encfile"
  205. tsrcfile=$(target_path $srcfile)
  206. tencfile=$(target_path $encfile)
  207. ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $additional_input \
  208. $ENC_OPTS $enc_opt $FLAGS -f $enc_fmt -y $tencfile || return
  209. do_md5sum $encfile
  210. echo $(wc -c $encfile)
  211. ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
  212. -f framecrc - || return
  213. test -z $ffprobe_opts || \
  214. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts $tencfile || return
  215. }
  216. stream_remux(){
  217. src_fmt=$1
  218. srcfile=$2
  219. enc_fmt=$3
  220. stream_maps=$4
  221. final_decode=$5
  222. ffprobe_opts=$7
  223. encfile="${outdir}/${test}.${enc_fmt}"
  224. test "$6" = -keep || cleanfiles="$cleanfiles $encfile"
  225. tsrcfile=$(target_path $srcfile)
  226. tencfile=$(target_path $encfile)
  227. ffmpeg -f $src_fmt -i $tsrcfile $stream_maps -codec copy $FLAGS \
  228. -f $enc_fmt -y $tencfile || return
  229. ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
  230. -f framecrc - || return
  231. test -z $ffprobe_opts || \
  232. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts $tencfile || return
  233. }
  234. # FIXME: There is a certain duplication between the avconv-related helper
  235. # functions above and below that should be refactored.
  236. ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
  237. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  238. pcm_src="${target_path}/tests/data/asynth1.sw"
  239. crcfile="tests/data/$test.lavf.crc"
  240. target_crcfile="${target_path}/$crcfile"
  241. [ "${V-0}" -gt 0 ] && echov=echov || echov=:
  242. echov(){
  243. echo "$@" >&3
  244. }
  245. AVCONV_OPTS="-nostdin -nostats -noauto_conversion_filters -y -cpuflags $cpuflags -filter_threads $threads"
  246. COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
  247. DEC_OPTS="$COMMON_OPTS -threads $threads"
  248. ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
  249. run_avconv(){
  250. $echov $ffmpeg2 $AVCONV_OPTS $*
  251. $ffmpeg2 $AVCONV_OPTS $*
  252. }
  253. do_avconv(){
  254. f="$1"
  255. shift
  256. set -- $* ${target_path}/$f
  257. run_avconv $*
  258. do_md5sum $f
  259. echo $(wc -c $f)
  260. }
  261. do_avconv_crc(){
  262. f="$1"
  263. shift
  264. run_avconv $* -f crc "$target_crcfile"
  265. echo "$f $(cat $crcfile)"
  266. }
  267. lavf_audio(){
  268. t="${test#lavf-}"
  269. outdir="tests/data/lavf"
  270. file=${outdir}/lavf.$t
  271. 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
  272. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $3 -i $target_path/$file
  273. }
  274. lavf_container(){
  275. t="${test#lavf-}"
  276. outdir="tests/data/lavf"
  277. file=${outdir}/lavf.$t
  278. 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
  279. test "$3" = "disable_crc" ||
  280. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $3
  281. }
  282. lavf_container_attach() { lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
  283. lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
  284. lavf_container_timecode_drop() { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }
  285. lavf_container_timecode()
  286. {
  287. lavf_container_timecode_nodrop "$@"
  288. lavf_container_timecode_drop "$@"
  289. lavf_container "" "$1"
  290. }
  291. lavf_container_fate()
  292. {
  293. t="${test#lavf-fate-}"
  294. outdir="tests/data/lavf-fate"
  295. file=${outdir}/lavf.$t
  296. input="${target_samples}/$1"
  297. do_avconv $file -auto_conversion_filters $DEC_OPTS $2 -i "$input" "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy
  298. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $3
  299. }
  300. lavf_image(){
  301. t="${test#lavf-}"
  302. outdir="tests/data/images/$t"
  303. mkdir -p "$outdir"
  304. file=${outdir}/%02d.$t
  305. run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 "$ENC_OPTS -metadata title=lavftest" -vf scale -frames 13 -y -qscale 10 $target_path/$file
  306. do_md5sum ${outdir}/02.$t
  307. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $2 -i $target_path/$file $2
  308. echo $(wc -c ${outdir}/02.$t)
  309. }
  310. lavf_image2pipe(){
  311. t="${test#lavf-}"
  312. t="${t%pipe}"
  313. outdir="tests/data/lavf"
  314. file=${outdir}/${t}pipe.$t
  315. 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
  316. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -f image2pipe -i $target_path/$file
  317. }
  318. lavf_video(){
  319. t="${test#lavf-}"
  320. outdir="tests/data/lavf"
  321. file=${outdir}/lavf.$t
  322. 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
  323. do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i $target_path/$file $1
  324. }
  325. refcmp_metadata(){
  326. refcmp=$1
  327. pixfmt=$2
  328. fuzz=${3:-0.001}
  329. ffmpeg $FLAGS $ENC_OPTS \
  330. -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
  331. -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
  332. }
  333. pixfmt_conversion(){
  334. conversion="${test#pixfmt-}"
  335. outdir="tests/data/pixfmt"
  336. raw_dst="$outdir/$conversion.out.yuv"
  337. file=${outdir}/${conversion}.yuv
  338. run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
  339. $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst
  340. do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
  341. $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
  342. }
  343. video_filter(){
  344. filters=$1
  345. shift
  346. label=${test#filter-}
  347. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  348. printf '%-20s' $label
  349. ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
  350. $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
  351. }
  352. pixfmts(){
  353. filter=${test#filter-pixfmts-}
  354. filter=${filter%_*}
  355. filter_args=$1
  356. prefilter_chain=$2
  357. nframes=${3:-1}
  358. showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
  359. scale_exclude_fmts=${outfile}_scale_exclude_fmts
  360. scale_in_fmts=${outfile}_scale_in_fmts
  361. scale_out_fmts=${outfile}_scale_out_fmts
  362. in_fmts=${outfile}_in_fmts
  363. # exclude pixel formats which are not supported as input
  364. $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
  365. $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
  366. comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
  367. $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
  368. pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
  369. outertest=$test
  370. for pix_fmt in $pix_fmts; do
  371. test=$pix_fmt
  372. video_filter "${prefilter_chain}scale,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
  373. done
  374. rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
  375. test=$outertest
  376. }
  377. gapless(){
  378. sample=$(target_path $1)
  379. extra_args=$2
  380. decfile1="${outdir}/${test}.out-1"
  381. decfile2="${outdir}/${test}.out-2"
  382. decfile3="${outdir}/${test}.out-3"
  383. cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
  384. # test packet data
  385. ffmpeg -auto_conversion_filters $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile1)
  386. do_md5sum $decfile1
  387. # test decoded (and cut) data
  388. ffmpeg -auto_conversion_filters $extra_args -i "$sample" -bitexact -f wav md5:
  389. # the same as above again, with seeking to the start
  390. ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile2)
  391. do_md5sum $decfile2
  392. ffmpeg -auto_conversion_filters $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
  393. # test packet data, with seeking to a specific position
  394. ffmpeg -auto_conversion_filters $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile3)
  395. do_md5sum $decfile3
  396. }
  397. gaplessenc(){
  398. sample=$(target_path $1)
  399. format=$2
  400. codec=$3
  401. file1="${outdir}/${test}.out-1"
  402. cleanfiles="$cleanfiles $file1"
  403. # test data after reencoding
  404. ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -af aresample -f $format -y "$(target_path "$file1")"
  405. probegaplessinfo "$(target_path "$file1")"
  406. }
  407. audio_match(){
  408. sample=$(target_path $1)
  409. trefile=$2
  410. extra_args=$3
  411. decfile="${outdir}/${test}.wav"
  412. cleanfiles="$cleanfiles $decfile"
  413. ffmpeg -auto_conversion_filters -i "$sample" -bitexact $extra_args -y $(target_path $decfile)
  414. tests/audiomatch${HOSTEXECSUF} $decfile $trefile
  415. }
  416. concat(){
  417. template=$1
  418. sample=$2
  419. mode=$3
  420. extra_args=$4
  421. concatfile="${outdir}/${test}.ffconcat"
  422. packetfile="${outdir}/${test}.ffprobe"
  423. cleanfiles="$concatfile $packetfile"
  424. awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
  425. if [ "$mode" = "md5" ]; then
  426. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -safe 0 $extra_args $(target_path $concatfile) | tr -d '\r' > $packetfile
  427. do_md5sum $packetfile
  428. else
  429. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -of compact=p=0:nk=1 -safe 0 $extra_args $(target_path $concatfile)
  430. fi
  431. }
  432. venc_data(){
  433. file=$1
  434. stream=$2
  435. frames=$3
  436. run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
  437. }
  438. null(){
  439. :
  440. }
  441. # Disable globbing: command arguments may contain globbing characters and
  442. # must be kept verbatim
  443. set -f
  444. exec 3>&2
  445. eval $command >"$outfile" 2>$errfile
  446. err=$?
  447. if [ $err -gt 128 ]; then
  448. sig=$(kill -l $err 2>/dev/null)
  449. test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
  450. fi
  451. if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
  452. case $cmp in
  453. diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
  454. rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
  455. oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
  456. stddev) stddev "$ref" "$outfile" >$cmpfile ;;
  457. oneline)oneline "$ref" "$outfile" >$cmpfile ;;
  458. grep) grep "$ref" "$errfile" >$cmpfile ;;
  459. null) cat "$outfile" >$cmpfile ;;
  460. esac
  461. cmperr=$?
  462. test $err = 0 && err=$cmperr
  463. if [ "$report_type" = "ignore" ]; then
  464. test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
  465. else
  466. test $err = 0 || cat $cmpfile
  467. fi
  468. else
  469. echo "reference file '$ref' not found"
  470. err=1
  471. fi
  472. if [ $err -eq 0 ] && test $report_type = "standard" ; then
  473. unset cmpo erro
  474. else
  475. cmpo="$($base64 <$cmpfile)"
  476. erro="$($base64 <$errfile)"
  477. fi
  478. echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
  479. if test $err != 0 && test $gen != "no" ; then
  480. echo "GEN $ref"
  481. cp -f "$outfile" "$ref"
  482. err=$?
  483. fi
  484. if test $err = 0; then
  485. if test $keep = 0; then
  486. rm -f $outfile $errfile $cmpfile $cleanfiles
  487. fi
  488. elif test $gen = "no"; then
  489. echo "Test $test failed. Look at $errfile for details."
  490. test "${V:-0}" -gt 0 && cat $errfile
  491. else
  492. echo "Updating reference failed, possibly no output file was generated."
  493. fi
  494. exit $err