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.

131 lines
3.1KB

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