Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 3 | rm logs_mono.txt |
| 4 | rm logs_stereo.txt |
| 5 | |
| 6 | if [ "$#" -ne "3" ]; then |
| 7 | echo "usage: run_vectors.sh <exec path> <vector path> <rate>" |
Jean-Marc Valin | 2d4f614 | 2011-10-28 16:16:35 -0400 | [diff] [blame] | 8 | exit 1 |
| 9 | fi |
| 10 | |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 11 | CMD_PATH=$1 |
| 12 | VECTOR_PATH=$2 |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 13 | RATE=$3 |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 14 | |
| 15 | OPUS_DEMO=$CMD_PATH/opus_demo |
| 16 | OPUS_COMPARE=$CMD_PATH/opus_compare |
| 17 | |
| 18 | if [ -d $VECTOR_PATH ]; then |
| 19 | echo Test vectors found in $VECTOR_PATH |
| 20 | else |
| 21 | echo No test vectors found |
Ralph Giles | 5f6e472 | 2012-03-19 17:10:13 -0700 | [diff] [blame] | 22 | #Don't make the test fail here because the test vectors |
| 23 | #will be distributed separately |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 24 | exit 0 |
| 25 | fi |
| 26 | |
| 27 | if [ -x $OPUS_DEMO ]; then |
| 28 | echo Decoding with $OPUS_DEMO |
| 29 | else |
| 30 | echo ERROR: Decoder not found: $OPUS_DEMO |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | echo "==============" |
| 35 | echo Testing mono |
| 36 | echo "==============" |
| 37 | echo |
| 38 | |
Jean-Marc Valin | 7227300 | 2012-04-20 10:26:08 -0400 | [diff] [blame] | 39 | for file in 01 02 03 04 05 06 07 08 09 10 11 12 |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 40 | do |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 41 | if [ -e $VECTOR_PATH/testvector$file.bit ]; then |
| 42 | echo Testing testvector$file |
Ralph Giles | 5f6e472 | 2012-03-19 17:10:13 -0700 | [diff] [blame] | 43 | else |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 44 | echo Bitstream file not found: testvector$file.bit |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 45 | fi |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 46 | if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mono.txt 2>&1; then |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 47 | echo successfully decoded |
| 48 | else |
| 49 | echo ERROR: decoding failed |
| 50 | exit 1 |
| 51 | fi |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 52 | $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1 |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 53 | float_ret=$? |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 54 | if [ "$float_ret" -eq "0" ]; then |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 55 | echo output matches reference |
| 56 | else |
| 57 | echo ERROR: output does not match reference |
| 58 | exit 1 |
| 59 | fi |
| 60 | echo |
| 61 | done |
| 62 | |
| 63 | echo "==============" |
| 64 | echo Testing stereo |
| 65 | echo "==============" |
| 66 | echo |
| 67 | |
Jean-Marc Valin | 7227300 | 2012-04-20 10:26:08 -0400 | [diff] [blame] | 68 | for file in 01 02 03 04 05 06 07 08 09 10 11 12 |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 69 | do |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 70 | if [ -e $VECTOR_PATH/testvector$file.bit ]; then |
| 71 | echo Testing testvector$file |
Ralph Giles | 5f6e472 | 2012-03-19 17:10:13 -0700 | [diff] [blame] | 72 | else |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 73 | echo Bitstream file not found: testvector$file |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 74 | fi |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 75 | if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_stereo.txt 2>&1; then |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 76 | echo successfully decoded |
| 77 | else |
| 78 | echo ERROR: decoding failed |
| 79 | exit 1 |
| 80 | fi |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 81 | $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1 |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 82 | float_ret=$? |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 83 | if [ "$float_ret" -eq "0" ]; then |
Jean-Marc Valin | ad20dd2 | 2011-10-28 12:09:00 -0400 | [diff] [blame] | 84 | echo output matches reference |
| 85 | else |
| 86 | echo ERROR: output does not match reference |
| 87 | exit 1 |
| 88 | fi |
| 89 | echo |
| 90 | done |
| 91 | |
| 92 | |
| 93 | |
| 94 | echo All tests have passed successfully |
Jean-Marc Valin | 17c5966 | 2012-02-17 16:09:21 -0500 | [diff] [blame] | 95 | grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}' |
| 96 | grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}' |