run_vectors.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_DEMO ]; then
  54. echo Decoding with $OPUS_DEMO
  55. else
  56. echo ERROR: Decoder not found: $OPUS_DEMO
  57. exit 1
  58. fi
  59. echo "=============="
  60. echo Testing mono
  61. echo "=============="
  62. echo
  63. for file in 01 02 03 04 05 06 07 08 09 10 11 12
  64. do
  65. if [ -e $VECTOR_PATH/testvector$file.bit ]; then
  66. echo Testing testvector$file
  67. else
  68. echo Bitstream file not found: testvector$file.bit
  69. fi
  70. if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mono.txt 2>&1; then
  71. echo successfully decoded
  72. else
  73. echo ERROR: decoding failed
  74. exit 1
  75. fi
  76. $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1
  77. float_ret=$?
  78. if [ "$float_ret" -eq "0" ]; then
  79. echo output matches reference
  80. else
  81. echo ERROR: output does not match reference
  82. exit 1
  83. fi
  84. echo
  85. done
  86. echo "=============="
  87. echo Testing stereo
  88. echo "=============="
  89. echo
  90. for file in 01 02 03 04 05 06 07 08 09 10 11 12
  91. do
  92. if [ -e $VECTOR_PATH/testvector$file.bit ]; then
  93. echo Testing testvector$file
  94. else
  95. echo Bitstream file not found: testvector$file
  96. fi
  97. if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_stereo.txt 2>&1; then
  98. echo successfully decoded
  99. else
  100. echo ERROR: decoding failed
  101. exit 1
  102. fi
  103. $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1
  104. float_ret=$?
  105. if [ "$float_ret" -eq "0" ]; then
  106. echo output matches reference
  107. else
  108. echo ERROR: output does not match reference
  109. exit 1
  110. fi
  111. echo
  112. done
  113. echo All tests have passed successfully
  114. grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}'
  115. grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}'