Skip to content

Commit 913cac3

Browse files
committed
Opus HD testvector script
1 parent 9bae4aa commit 913cac3

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

tests/run_opushd_vectors.sh

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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 -f logs_mono.txt logs_mono2.txt
37+
rm -f logs_stereo.txt logs_stereo2.txt
38+
39+
if [ "$#" -ne "2" ]; then
40+
echo "usage: run_vectors.sh <exec path> <vector path>"
41+
exit 1
42+
fi
43+
44+
CMD_PATH=$1
45+
VECTOR_PATH=$2
46+
RATE=96000
47+
48+
: ${OPUS_DEMO:=$CMD_PATH/opus_demo}
49+
: ${QEXT_COMPARE:=$CMD_PATH/qext_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 "$QEXT_COMPARE" ]; then
61+
echo "ERROR: Compare program not found: $QEXT_COMPARE"
62+
exit 1
63+
fi
64+
65+
if [ -x "$OPUS_DEMO" ]; then
66+
echo "Decoding with $OPUS_DEMO"
67+
else
68+
echo "ERROR: Decoder not found: $OPUS_DEMO"
69+
exit 1
70+
fi
71+
72+
echo "============================"
73+
echo "Testing original testvectors"
74+
echo "============================"
75+
echo
76+
77+
78+
for file in 01 02 03 04 05 06 07 08 09 10 11 12
79+
do
80+
if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then
81+
echo "Testing testvector$file"
82+
else
83+
echo "Bitstream file not found: testvector$file"
84+
fi
85+
if "$OPUS_DEMO" -d "$RATE" 2 -ignore_extensions -f32 "$VECTOR_PATH/testvector$file.bit" tmp.out >> logs_stereo.txt 2>&1; then
86+
echo "successfully decoded"
87+
else
88+
echo "ERROR: decoding failed"
89+
exit 1
90+
fi
91+
"$QEXT_COMPARE" -s -r "$RATE" -f32 -thresholds 0.05 .1 .1 "$VECTOR_PATH/testvector${file}_96k.f32" tmp.out >> logs_stereo.txt 2>&1
92+
if [ "$?" -eq "0" ]; then
93+
echo "output matches reference"
94+
else
95+
echo "ERROR: output does not match reference"
96+
exit 1
97+
fi
98+
echo
99+
done
100+
101+
102+
echo "==========================="
103+
echo "Testing Opus HD testvectors"
104+
echo "==========================="
105+
echo
106+
for file in 01 02 03 04 05 06
107+
do
108+
if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then
109+
echo "Testing testvector$file"
110+
else
111+
echo "Bitstream file not found: testvector$file"
112+
fi
113+
if "$OPUS_DEMO" -d "$RATE" 2 -f32 "$VECTOR_PATH/qext_vector$file.bit" tmp.out >> logs_qext.txt 2>&1; then
114+
echo "successfully decoded"
115+
else
116+
echo "ERROR: decoding failed"
117+
exit 1
118+
fi
119+
"$QEXT_COMPARE" -s -r "$RATE" -f32 -thresholds 0.05 .1 .1 "$VECTOR_PATH/qext_vector${file}dec.f32" tmp.out >> logs_qext.txt 2>&1
120+
if [ "$?" -eq "0" ]; then
121+
echo "output matches reference"
122+
else
123+
echo "ERROR: output does not match reference"
124+
exit 1
125+
fi
126+
echo
127+
done
128+
129+
echo "=================================="
130+
echo "Testing Opus HD fuzzng testvectors"
131+
echo "=================================="
132+
echo
133+
for file in 01 02 03 04 05 06
134+
do
135+
if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then
136+
echo "Testing testvector$file"
137+
else
138+
echo "Bitstream file not found: testvector$file"
139+
fi
140+
if "$OPUS_DEMO" -d "$RATE" 2 -f32 "$VECTOR_PATH/qext_vector${file}fuzz.bit" tmp.out >> logs_qextfuzz.txt 2>&1; then
141+
echo "successfully decoded"
142+
else
143+
echo "ERROR: decoding failed"
144+
exit 1
145+
fi
146+
"$QEXT_COMPARE" -s -r "$RATE" -f32 -thresholds 0.1 .5 1 "$VECTOR_PATH/qext_vector${file}fuzzdec.f32" tmp.out >> logs_qextfuzz.txt 2>&1
147+
if [ "$?" -eq "0" ]; then
148+
echo "output matches reference"
149+
else
150+
echo "ERROR: output does not match reference"
151+
exit 1
152+
fi
153+
echo
154+
done
155+
156+
157+
158+
echo "All tests have passed successfully"

0 commit comments

Comments
 (0)