regression-funcs.sh 2.6 KB

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