blob: 1d447c43f5967706bd309ebbf22038a1f3a11f25 [file] [log] [blame]
Jean-Marc Valinad20dd22011-10-28 12:09:00 -04001#!/bin/sh
2
Jean-Marc Valin00898f22012-10-30 01:26:36 -04003# 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
Jean-Marc Valin17c59662012-02-17 16:09:21 -050036rm logs_mono.txt
37rm logs_stereo.txt
38
39if [ "$#" -ne "3" ]; then
40 echo "usage: run_vectors.sh <exec path> <vector path> <rate>"
Jean-Marc Valin2d4f6142011-10-28 16:16:35 -040041 exit 1
42fi
43
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040044CMD_PATH=$1
45VECTOR_PATH=$2
Jean-Marc Valin17c59662012-02-17 16:09:21 -050046RATE=$3
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040047
Jonathan Lennox3a1dc9d2015-08-04 15:24:21 -040048: ${OPUS_DEMO:=$CMD_PATH/opus_demo}
49: ${OPUS_COMPARE:=$CMD_PATH/opus_compare}
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040050
51if [ -d $VECTOR_PATH ]; then
52 echo Test vectors found in $VECTOR_PATH
53else
54 echo No test vectors found
Ralph Giles5f6e4722012-03-19 17:10:13 -070055 #Don't make the test fail here because the test vectors
56 #will be distributed separately
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040057 exit 0
58fi
59
Aurélien Zanellifcecd292013-05-27 15:54:31 +020060if [ ! -x $OPUS_COMPARE ]; then
61 echo ERROR: Compare program not found: $OPUS_COMPARE
62 exit 1
63fi
64
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040065if [ -x $OPUS_DEMO ]; then
66 echo Decoding with $OPUS_DEMO
67else
68 echo ERROR: Decoder not found: $OPUS_DEMO
69 exit 1
70fi
71
72echo "=============="
73echo Testing mono
74echo "=============="
75echo
76
Jean-Marc Valin72273002012-04-20 10:26:08 -040077for file in 01 02 03 04 05 06 07 08 09 10 11 12
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040078do
Jean-Marc Valin17c59662012-02-17 16:09:21 -050079 if [ -e $VECTOR_PATH/testvector$file.bit ]; then
80 echo Testing testvector$file
Ralph Giles5f6e4722012-03-19 17:10:13 -070081 else
Jean-Marc Valin17c59662012-02-17 16:09:21 -050082 echo Bitstream file not found: testvector$file.bit
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040083 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050084 if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mono.txt 2>&1; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040085 echo successfully decoded
86 else
87 echo ERROR: decoding failed
88 exit 1
89 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050090 $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040091 float_ret=$?
Jean-Marc Valin17c59662012-02-17 16:09:21 -050092 if [ "$float_ret" -eq "0" ]; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040093 echo output matches reference
94 else
95 echo ERROR: output does not match reference
96 exit 1
97 fi
98 echo
99done
100
101echo "=============="
102echo Testing stereo
103echo "=============="
104echo
105
Jean-Marc Valin72273002012-04-20 10:26:08 -0400106for file in 01 02 03 04 05 06 07 08 09 10 11 12
Jean-Marc Valinad20dd22011-10-28 12:09:00 -0400107do
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500108 if [ -e $VECTOR_PATH/testvector$file.bit ]; then
109 echo Testing testvector$file
Ralph Giles5f6e4722012-03-19 17:10:13 -0700110 else
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500111 echo Bitstream file not found: testvector$file
Jean-Marc Valinad20dd22011-10-28 12:09:00 -0400112 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500113 if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_stereo.txt 2>&1; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -0400114 echo successfully decoded
115 else
116 echo ERROR: decoding failed
117 exit 1
118 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500119 $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1
Jean-Marc Valinad20dd22011-10-28 12:09:00 -0400120 float_ret=$?
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500121 if [ "$float_ret" -eq "0" ]; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -0400122 echo output matches reference
123 else
124 echo ERROR: output does not match reference
125 exit 1
126 fi
127 echo
128done
129
130
131
132echo All tests have passed successfully
Jean-Marc Valin17c59662012-02-17 16:09:21 -0500133grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}'
134grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}'