You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.0KB

  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. logdir="$datadir/regression/$test_ref"
  15. logfile="$logdir/$test"
  16. outfile="$datadir/$test_ref/"
  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. cleanfiles="$raw_dst $pcm_dst $crcfile $bench $bench2"
  33. trap 'rm -f -- $cleanfiles' EXIT
  34. mkdir -p "$datadir"
  35. mkdir -p "$outfile"
  36. mkdir -p "$logdir"
  37. (exec >&3) 2>/dev/null || exec 3>&2
  38. [ "${V-0}" -gt 0 ] && echov=echov || echov=:
  39. [ "${V-0}" -gt 1 ] || exec 2>$errfile
  40. echov(){
  41. echo "$@" >&3
  42. }
  43. . $(dirname $0)/md5.sh
  44. FFMPEG_OPTS="-v 0 -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact"
  45. run_ffmpeg()
  46. {
  47. $echov $ffmpeg $FFMPEG_OPTS $*
  48. $ffmpeg $FFMPEG_OPTS $*
  49. }
  50. do_ffmpeg()
  51. {
  52. f="$1"
  53. shift
  54. set -- $* ${target_path}/$f
  55. $echov $ffmpeg $FFMPEG_OPTS $*
  56. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  57. do_md5sum $f >> $logfile
  58. if [ $f = $raw_dst ] ; then
  59. $tiny_psnr $f $raw_ref >> $logfile
  60. elif [ $f = $pcm_dst ] ; then
  61. $tiny_psnr $f $pcm_ref 2 >> $logfile
  62. else
  63. wc -c $f >> $logfile
  64. fi
  65. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  66. echo $(cat $bench2) $f >> $benchfile
  67. }
  68. do_ffmpeg_nomd5()
  69. {
  70. f="$1"
  71. shift
  72. set -- $* ${target_path}/$f
  73. $echov $ffmpeg $FFMPEG_OPTS $*
  74. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  75. if [ $f = $raw_dst ] ; then
  76. $tiny_psnr $f $raw_ref >> $logfile
  77. elif [ $f = $pcm_dst ] ; then
  78. $tiny_psnr $f $pcm_ref 2 >> $logfile
  79. else
  80. wc -c $f >> $logfile
  81. fi
  82. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  83. echo $(cat $bench2) $f >> $benchfile
  84. }
  85. do_ffmpeg_crc()
  86. {
  87. f="$1"
  88. shift
  89. $echov $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
  90. $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
  91. echo "$f $(cat $crcfile)" >> $logfile
  92. }
  93. do_ffmpeg_nocheck()
  94. {
  95. f="$1"
  96. shift
  97. $echov $ffmpeg $FFMPEG_OPTS $*
  98. $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
  99. expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
  100. echo $(cat $bench2) $f >> $benchfile
  101. }
  102. do_video_decoding()
  103. {
  104. do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2
  105. }
  106. do_video_encoding()
  107. {
  108. file=${outfile}$1
  109. do_ffmpeg $file $2 -f image2 -vcodec pgmyuv -i $raw_src $3
  110. }
  111. do_audio_encoding()
  112. {
  113. file=${outfile}$1
  114. do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $3
  115. }
  116. do_audio_decoding()
  117. {
  118. do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav
  119. }