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.

125 lines
2.4KB

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