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