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