run_vectors.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/sh
  2. # Copyright (c) 2011-2012 Jean-Marc Valin
  3. #
  4. # This file is extracted from RFC6716. Please see that RFC for additional
  5. # information.
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. #
  11. # - Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # - Redistributions in binary form must reproduce the above copyright
  15. # notice, this list of conditions and the following disclaimer in the
  16. # documentation and/or other materials provided with the distribution.
  17. #
  18. # - Neither the name of Internet Society, IETF or IETF Trust, nor the
  19. # names of specific contributors, may be used to endorse or promote
  20. # products derived from this software without specific prior written
  21. # permission.
  22. #
  23. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  27. # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  28. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. rm logs_mono.txt
  35. rm logs_stereo.txt
  36. if [ "$#" -ne "3" ]; then
  37. echo "usage: run_vectors.sh <exec path> <vector path> <rate>"
  38. exit 1
  39. fi
  40. CMD_PATH=$1
  41. VECTOR_PATH=$2
  42. RATE=$3
  43. : ${OPUS_DEMO:=$CMD_PATH/opus_demo}
  44. : ${OPUS_COMPARE:=$CMD_PATH/opus_compare}
  45. if [ -d $VECTOR_PATH ]; then
  46. echo Test vectors found in $VECTOR_PATH
  47. else
  48. echo No test vectors found
  49. #Don't make the test fail here because the test vectors
  50. #will be distributed separately
  51. exit 0
  52. fi
  53. if [ ! -x $OPUS_COMPARE ]; then
  54. echo ERROR: Compare program not found: $OPUS_COMPARE
  55. exit 1
  56. fi
  57. if [ -x $OPUS_DEMO ]; then
  58. echo Decoding with $OPUS_DEMO
  59. else
  60. echo ERROR: Decoder not found: $OPUS_DEMO
  61. exit 1
  62. fi
  63. echo "=============="
  64. echo Testing mono
  65. echo "=============="
  66. echo
  67. for file in 01 02 03 04 05 06 07 08 09 10 11 12
  68. do
  69. if [ -e $VECTOR_PATH/testvector$file.bit ]; then
  70. echo Testing testvector$file
  71. else
  72. echo Bitstream file not found: testvector$file.bit
  73. fi
  74. if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mono.txt 2>&1; then
  75. echo successfully decoded
  76. else
  77. echo ERROR: decoding failed
  78. exit 1
  79. fi
  80. $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1
  81. float_ret=$?
  82. if [ "$float_ret" -eq "0" ]; then
  83. echo output matches reference
  84. else
  85. echo ERROR: output does not match reference
  86. exit 1
  87. fi
  88. echo
  89. done
  90. echo "=============="
  91. echo Testing stereo
  92. echo "=============="
  93. echo
  94. for file in 01 02 03 04 05 06 07 08 09 10 11 12
  95. do
  96. if [ -e $VECTOR_PATH/testvector$file.bit ]; then
  97. echo Testing testvector$file
  98. else
  99. echo Bitstream file not found: testvector$file
  100. fi
  101. if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_stereo.txt 2>&1; then
  102. echo successfully decoded
  103. else
  104. echo ERROR: decoding failed
  105. exit 1
  106. fi
  107. $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1
  108. float_ret=$?
  109. if [ "$float_ret" -eq "0" ]; then
  110. echo output matches reference
  111. else
  112. echo ERROR: output does not match reference
  113. exit 1
  114. fi
  115. echo
  116. done
  117. echo All tests have passed successfully
  118. grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}'
  119. grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}'