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