OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2011-2012 Jean-Marc Valin | 3 # Copyright (c) 2011-2012 Jean-Marc Valin |
4 # | 4 # |
5 # This file is extracted from RFC6716. Please see that RFC for additional | 5 # This file is extracted from RFC6716. Please see that RFC for additional |
6 # information. | 6 # information. |
7 # | 7 # |
8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
9 # modification, are permitted provided that the following conditions | 9 # modification, are permitted provided that the following conditions |
10 # are met: | 10 # are met: |
(...skipping 15 matching lines...) Expand all Loading... |
26 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 26 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
27 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | 27 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
28 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 28 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
29 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 29 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
30 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 30 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
31 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 31 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
32 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 32 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
33 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 34 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | 35 |
36 rm logs_mono.txt | 36 rm -f logs_mono.txt logs_mono2.txt |
37 rm logs_stereo.txt | 37 rm -f logs_stereo.txt logs_stereo2.txt |
38 | 38 |
39 if [ "$#" -ne "3" ]; then | 39 if [ "$#" -ne "3" ]; then |
40 echo "usage: run_vectors.sh <exec path> <vector path> <rate>" | 40 echo "usage: run_vectors.sh <exec path> <vector path> <rate>" |
41 exit 1 | 41 exit 1 |
42 fi | 42 fi |
43 | 43 |
44 CMD_PATH=$1 | 44 CMD_PATH=$1 |
45 VECTOR_PATH=$2 | 45 VECTOR_PATH=$2 |
46 RATE=$3 | 46 RATE=$3 |
47 | 47 |
48 : ${OPUS_DEMO:=$CMD_PATH/opus_demo} | 48 : ${OPUS_DEMO:=$CMD_PATH/opus_demo} |
49 : ${OPUS_COMPARE:=$CMD_PATH/opus_compare} | 49 : ${OPUS_COMPARE:=$CMD_PATH/opus_compare} |
50 | 50 |
51 if [ -d $VECTOR_PATH ]; then | 51 if [ -d "$VECTOR_PATH" ]; then |
52 echo Test vectors found in $VECTOR_PATH | 52 echo "Test vectors found in $VECTOR_PATH" |
53 else | 53 else |
54 echo No test vectors found | 54 echo "No test vectors found" |
55 #Don't make the test fail here because the test vectors | 55 #Don't make the test fail here because the test vectors |
56 #will be distributed separately | 56 #will be distributed separately |
57 exit 0 | 57 exit 0 |
58 fi | 58 fi |
59 | 59 |
60 if [ ! -x $OPUS_COMPARE ]; then | 60 if [ ! -x "$OPUS_COMPARE" ]; then |
61 echo ERROR: Compare program not found: $OPUS_COMPARE | 61 echo "ERROR: Compare program not found: $OPUS_COMPARE" |
62 exit 1 | 62 exit 1 |
63 fi | 63 fi |
64 | 64 |
65 if [ -x $OPUS_DEMO ]; then | 65 if [ -x "$OPUS_DEMO" ]; then |
66 echo Decoding with $OPUS_DEMO | 66 echo "Decoding with $OPUS_DEMO" |
67 else | 67 else |
68 echo ERROR: Decoder not found: $OPUS_DEMO | 68 echo "ERROR: Decoder not found: $OPUS_DEMO" |
69 exit 1 | 69 exit 1 |
70 fi | 70 fi |
71 | 71 |
72 echo "==============" | 72 echo "==============" |
73 echo Testing mono | 73 echo "Testing mono" |
74 echo "==============" | 74 echo "==============" |
75 echo | 75 echo |
76 | 76 |
77 for file in 01 02 03 04 05 06 07 08 09 10 11 12 | 77 for file in 01 02 03 04 05 06 07 08 09 10 11 12 |
78 do | 78 do |
79 if [ -e $VECTOR_PATH/testvector$file.bit ]; then | 79 if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then |
80 echo Testing testvector$file | 80 echo "Testing testvector$file" |
81 else | 81 else |
82 echo Bitstream file not found: testvector$file.bit | 82 echo "Bitstream file not found: testvector$file.bit" |
83 fi | 83 fi |
84 if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mo
no.txt 2>&1; then | 84 if "$OPUS_DEMO" -d "$RATE" 1 "$VECTOR_PATH/testvector$file.bit" tmp.out >> l
ogs_mono.txt 2>&1; then |
85 echo successfully decoded | 85 echo "successfully decoded" |
86 else | 86 else |
87 echo ERROR: decoding failed | 87 echo "ERROR: decoding failed" |
88 exit 1 | 88 exit 1 |
89 fi | 89 fi |
90 $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono
.txt 2>&1 | 90 "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >> l
ogs_mono.txt 2>&1 |
91 float_ret=$? | 91 float_ret=$? |
92 if [ "$float_ret" -eq "0" ]; then | 92 "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out >>
logs_mono2.txt 2>&1 |
93 echo output matches reference | 93 float_ret2=$? |
| 94 if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then |
| 95 echo "output matches reference" |
94 else | 96 else |
95 echo ERROR: output does not match reference | 97 echo "ERROR: output does not match reference" |
96 exit 1 | 98 exit 1 |
97 fi | 99 fi |
98 echo | 100 echo |
99 done | 101 done |
100 | 102 |
101 echo "==============" | 103 echo "==============" |
102 echo Testing stereo | 104 echo Testing stereo |
103 echo "==============" | 105 echo "==============" |
104 echo | 106 echo |
105 | 107 |
106 for file in 01 02 03 04 05 06 07 08 09 10 11 12 | 108 for file in 01 02 03 04 05 06 07 08 09 10 11 12 |
107 do | 109 do |
108 if [ -e $VECTOR_PATH/testvector$file.bit ]; then | 110 if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then |
109 echo Testing testvector$file | 111 echo "Testing testvector$file" |
110 else | 112 else |
111 echo Bitstream file not found: testvector$file | 113 echo "Bitstream file not found: testvector$file" |
112 fi | 114 fi |
113 if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_st
ereo.txt 2>&1; then | 115 if "$OPUS_DEMO" -d "$RATE" 2 "$VECTOR_PATH/testvector$file.bit" tmp.out >> l
ogs_stereo.txt 2>&1; then |
114 echo successfully decoded | 116 echo "successfully decoded" |
115 else | 117 else |
116 echo ERROR: decoding failed | 118 echo "ERROR: decoding failed" |
117 exit 1 | 119 exit 1 |
118 fi | 120 fi |
119 $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_s
tereo.txt 2>&1 | 121 "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >
> logs_stereo.txt 2>&1 |
120 float_ret=$? | 122 float_ret=$? |
121 if [ "$float_ret" -eq "0" ]; then | 123 "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out
>> logs_stereo2.txt 2>&1 |
122 echo output matches reference | 124 float_ret2=$? |
| 125 if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then |
| 126 echo "output matches reference" |
123 else | 127 else |
124 echo ERROR: output does not match reference | 128 echo "ERROR: output does not match reference" |
125 exit 1 | 129 exit 1 |
126 fi | 130 fi |
127 echo | 131 echo |
128 done | 132 done |
129 | 133 |
130 | 134 |
131 | 135 |
132 echo All tests have passed successfully | 136 echo "All tests have passed successfully" |
133 grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is",
sum/NR, "%"}' | 137 mono1=`grep quality logs_mono.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; e
lse sum = 0; print sum}'` |
134 grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality i
s", sum/NR, "%"}' | 138 mono2=`grep quality logs_mono2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12;
else sum = 0; print sum}'` |
| 139 echo $mono1 $mono2 | awk '{if ($2 > $1) $1 = $2; print "Average mono quality is"
, $1, "%"}' |
| 140 |
| 141 stereo1=`grep quality logs_stereo.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 1
2; else sum = 0; print sum}'` |
| 142 stereo2=`grep quality logs_stereo2.txt | awk '{sum+=$4}END{if (NR == 12) sum /=
12; else sum = 0; print sum}'` |
| 143 echo $stereo1 $stereo2 | awk '{if ($2 > $1) $1 = $2; print "Average stereo quali
ty is", $1, "%"}' |
OLD | NEW |