blob: 3e021afa8bc116e383be517ef2096f92b810dce0 [file] [log] [blame]
Jean-Marc Valinad20dd22011-10-28 12:09:00 -04001#!/bin/sh
2
Jean-Marc Valin17c59662012-02-17 16:09:21 -05003rm logs_mono.txt
4rm logs_stereo.txt
5
6if [ "$#" -ne "3" ]; then
7 echo "usage: run_vectors.sh <exec path> <vector path> <rate>"
Jean-Marc Valin2d4f6142011-10-28 16:16:35 -04008 exit 1
9fi
10
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040011CMD_PATH=$1
12VECTOR_PATH=$2
Jean-Marc Valin17c59662012-02-17 16:09:21 -050013RATE=$3
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040014
15OPUS_DEMO=$CMD_PATH/opus_demo
16OPUS_COMPARE=$CMD_PATH/opus_compare
17
18if [ -d $VECTOR_PATH ]; then
19 echo Test vectors found in $VECTOR_PATH
20else
21 echo No test vectors found
Ralph Giles5f6e4722012-03-19 17:10:13 -070022 #Don't make the test fail here because the test vectors
23 #will be distributed separately
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040024 exit 0
25fi
26
27if [ -x $OPUS_DEMO ]; then
28 echo Decoding with $OPUS_DEMO
29else
30 echo ERROR: Decoder not found: $OPUS_DEMO
31 exit 1
32fi
33
34echo "=============="
35echo Testing mono
36echo "=============="
37echo
38
Jean-Marc Valin72273002012-04-20 10:26:08 -040039for file in 01 02 03 04 05 06 07 08 09 10 11 12
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040040do
Jean-Marc Valin17c59662012-02-17 16:09:21 -050041 if [ -e $VECTOR_PATH/testvector$file.bit ]; then
42 echo Testing testvector$file
Ralph Giles5f6e4722012-03-19 17:10:13 -070043 else
Jean-Marc Valin17c59662012-02-17 16:09:21 -050044 echo Bitstream file not found: testvector$file.bit
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040045 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050046 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 -040047 echo successfully decoded
48 else
49 echo ERROR: decoding failed
50 exit 1
51 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050052 $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040053 float_ret=$?
Jean-Marc Valin17c59662012-02-17 16:09:21 -050054 if [ "$float_ret" -eq "0" ]; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040055 echo output matches reference
56 else
57 echo ERROR: output does not match reference
58 exit 1
59 fi
60 echo
61done
62
63echo "=============="
64echo Testing stereo
65echo "=============="
66echo
67
Jean-Marc Valin72273002012-04-20 10:26:08 -040068for file in 01 02 03 04 05 06 07 08 09 10 11 12
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040069do
Jean-Marc Valin17c59662012-02-17 16:09:21 -050070 if [ -e $VECTOR_PATH/testvector$file.bit ]; then
71 echo Testing testvector$file
Ralph Giles5f6e4722012-03-19 17:10:13 -070072 else
Jean-Marc Valin17c59662012-02-17 16:09:21 -050073 echo Bitstream file not found: testvector$file
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040074 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050075 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 -040076 echo successfully decoded
77 else
78 echo ERROR: decoding failed
79 exit 1
80 fi
Jean-Marc Valin17c59662012-02-17 16:09:21 -050081 $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 -040082 float_ret=$?
Jean-Marc Valin17c59662012-02-17 16:09:21 -050083 if [ "$float_ret" -eq "0" ]; then
Jean-Marc Valinad20dd22011-10-28 12:09:00 -040084 echo output matches reference
85 else
86 echo ERROR: output does not match reference
87 exit 1
88 fi
89 echo
90done
91
92
93
94echo All tests have passed successfully
Jean-Marc Valin17c59662012-02-17 16:09:21 -050095grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}'
96grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}'