regression-funcs.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/sh
  2. #
  3. # common regression functions for ffmpeg
  4. #
  5. #
  6. test="${1#regtest-}"
  7. test_ref=$2
  8. raw_src_dir=$3
  9. target_exec=$4
  10. target_path=$5
  11. datadir="./tests/data"
  12. target_datadir="${target_path}/${datadir}"
  13. this="$test.$test_ref"
  14. logfile="$datadir/$this.regression"
  15. outfile="$datadir/$test_ref/"
  16. errfile="$datadir/$this.err"
  17. # various files
  18. ffmpeg="$target_exec ${target_path}/ffmpeg"
  19. tiny_psnr="tests/tiny_psnr"
  20. benchfile="$datadir/$this.bench"
  21. bench="$datadir/$this.bench.tmp"
  22. bench2="$datadir/$this.bench2.tmp"
  23. raw_src="${target_path}/$raw_src_dir/%02d.pgm"
  24. raw_dst="$datadir/$this.out.yuv"
  25. raw_ref="$datadir/$test_ref.ref.yuv"
  26. pcm_src="$target_datadir/asynth1.sw"
  27. pcm_dst="$datadir/$this.out.wav"
  28. pcm_ref="$datadir/$test_ref.ref.wav"
  29. crcfile="$datadir/$this.crc"
  30. target_crcfile="$target_datadir/$this.crc"
  31. mkdir -p "$datadir"
  32. mkdir -p "$outfile"
  33. [ "${V-0}" -gt 0 ] && echov=echo || echov=:
  34. [ "${V-0}" -gt 1 ] || exec 2>$errfile
  35. . $(dirname $0)/md5.sh
  36. FFMPEG_OPTS="-v 0 -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact"
  37. do_ffmpeg()
  38. {
  39. f="$1"
  40. shift
  41. set -- $* ${target_path}/$f
  42. $echov $ffmpeg $FFMPEG_OPTS $*
  43. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  44. do_md5sum $f >> $logfile
  45. if [ $f = $raw_dst ] ; then
  46. $tiny_psnr $f $raw_ref >> $logfile
  47. elif [ $f = $pcm_dst ] ; then
  48. $tiny_psnr $f $pcm_ref 2 >> $logfile
  49. else
  50. wc -c $f >> $logfile
  51. fi
  52. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  53. echo $(cat $bench2) $f >> $benchfile
  54. }
  55. do_ffmpeg_nomd5()
  56. {
  57. f="$1"
  58. shift
  59. set -- $* ${target_path}/$f
  60. $echov $ffmpeg $FFMPEG_OPTS $*
  61. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  62. if [ $f = $raw_dst ] ; then
  63. $tiny_psnr $f $raw_ref >> $logfile
  64. elif [ $f = $pcm_dst ] ; then
  65. $tiny_psnr $f $pcm_ref 2 >> $logfile
  66. else
  67. wc -c $f >> $logfile
  68. fi
  69. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  70. echo $(cat $bench2) $f >> $benchfile
  71. }
  72. do_ffmpeg_crc()
  73. {
  74. f="$1"
  75. shift
  76. $echov $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
  77. $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
  78. echo "$f $(cat $crcfile)" >> $logfile
  79. rm -f "$crcfile"
  80. }
  81. do_ffmpeg_nocheck()
  82. {
  83. f="$1"
  84. shift
  85. $echov $ffmpeg $FFMPEG_OPTS $*
  86. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  87. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  88. echo $(cat $bench2) $f >> $benchfile
  89. }
  90. do_video_decoding()
  91. {
  92. do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2
  93. rm -f $raw_dst
  94. }
  95. do_video_encoding()
  96. {
  97. file=${outfile}$1
  98. do_ffmpeg $file $2 -f image2 -vcodec pgmyuv -i $raw_src $3
  99. }
  100. do_audio_encoding()
  101. {
  102. file=${outfile}$1
  103. do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $3
  104. }
  105. do_audio_decoding()
  106. {
  107. do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav
  108. }