regression-funcs.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. tool=$8
  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}/${tool}"
  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"
  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. wc -c $f
  59. fi
  60. }
  61. do_avconv_nomd5()
  62. {
  63. f="$1"
  64. shift
  65. set -- $* ${target_path}/$f
  66. run_avconv $*
  67. if [ $f = $raw_dst ] ; then
  68. $tiny_psnr $f $raw_ref
  69. elif [ $f = $pcm_dst ] ; then
  70. $tiny_psnr $f $pcm_ref 2
  71. else
  72. wc -c $f
  73. fi
  74. }
  75. do_avconv_crc()
  76. {
  77. f="$1"
  78. shift
  79. run_avconv $* -f crc "$target_crcfile"
  80. echo "$f $(cat $crcfile)"
  81. }
  82. do_video_decoding()
  83. {
  84. do_avconv $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS -vsync 0 $2
  85. }
  86. do_video_encoding()
  87. {
  88. file=${outfile}$1
  89. do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2
  90. }
  91. do_video_encoding_nomd5()
  92. {
  93. file=${outfile}$1
  94. do_avconv_nomd5 $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2
  95. }
  96. do_audio_encoding()
  97. {
  98. file=${outfile}$1
  99. do_avconv $file $DEC_OPTS -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2
  100. }
  101. do_audio_decoding()
  102. {
  103. do_avconv $pcm_dst $DEC_OPTS -i $target_path/$file -sample_fmt s16 -f wav
  104. }