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.

103 lines
2.0KB

  1. #!/bin/sh
  2. #
  3. # common regression functions for avconv
  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. cpuflags=${8:-all}
  13. datadir="./tests/data"
  14. target_datadir="${target_path}/${datadir}"
  15. this="$test.$test_ref"
  16. outfile="$datadir/$test_ref/"
  17. # various files
  18. avconv="$target_exec ${target_path}/avconv"
  19. tiny_psnr="tests/tiny_psnr"
  20. raw_src="${target_path}/$raw_src_dir/%02d.pgm"
  21. raw_dst="$datadir/$this.out.yuv"
  22. raw_ref="$datadir/$test_ref.ref.yuv"
  23. pcm_src="$target_datadir/asynth1.sw"
  24. pcm_dst="$datadir/$this.out.wav"
  25. pcm_ref="$datadir/$test_ref.ref.wav"
  26. crcfile="$datadir/$this.crc"
  27. target_crcfile="$target_datadir/$this.crc"
  28. cleanfiles="$raw_dst $pcm_dst $crcfile"
  29. trap 'rm -f -- $cleanfiles' EXIT
  30. mkdir -p "$datadir"
  31. mkdir -p "$outfile"
  32. [ "${V-0}" -gt 0 ] && echov=echov || echov=:
  33. echov(){
  34. echo "$@" >&3
  35. }
  36. . $(dirname $0)/md5.sh
  37. AVCONV_OPTS="-nostats -y -cpuflags $cpuflags"
  38. COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact"
  39. DEC_OPTS="$COMMON_OPTS -threads $threads"
  40. ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
  41. run_avconv()
  42. {
  43. $echov $avconv $AVCONV_OPTS $*
  44. $avconv $AVCONV_OPTS $*
  45. }
  46. do_avconv()
  47. {
  48. f="$1"
  49. shift
  50. set -- $* ${target_path}/$f
  51. run_avconv $*
  52. do_md5sum $f
  53. if [ $f = $raw_dst ] ; then
  54. $tiny_psnr $f $raw_ref
  55. elif [ $f = $pcm_dst ] ; then
  56. $tiny_psnr $f $pcm_ref 2
  57. else
  58. echo $(wc -c $f)
  59. fi
  60. }
  61. do_avconv_crc()
  62. {
  63. f="$1"
  64. shift
  65. run_avconv $* -f crc "$target_crcfile"
  66. echo "$f $(cat $crcfile)"
  67. }
  68. do_video_decoding()
  69. {
  70. do_avconv $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS $2
  71. }
  72. do_video_encoding()
  73. {
  74. file=${outfile}$1
  75. do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2
  76. }
  77. do_audio_encoding()
  78. {
  79. file=${outfile}$1
  80. do_avconv $file $DEC_OPTS -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2
  81. }
  82. do_audio_decoding()
  83. {
  84. do_avconv $pcm_dst $DEC_OPTS -i $target_path/$file -sample_fmt s16 -f wav
  85. }