regression-funcs.sh 3.1 KB

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