Chris@69: #!/bin/sh Chris@69: Chris@69: # Copyright (c) 2011-2012 Jean-Marc Valin Chris@69: # Chris@69: # This file is extracted from RFC6716. Please see that RFC for additional Chris@69: # information. Chris@69: # Chris@69: # Redistribution and use in source and binary forms, with or without Chris@69: # modification, are permitted provided that the following conditions Chris@69: # are met: Chris@69: # Chris@69: # - Redistributions of source code must retain the above copyright Chris@69: # notice, this list of conditions and the following disclaimer. Chris@69: # Chris@69: # - Redistributions in binary form must reproduce the above copyright Chris@69: # notice, this list of conditions and the following disclaimer in the Chris@69: # documentation and/or other materials provided with the distribution. Chris@69: # Chris@69: # - Neither the name of Internet Society, IETF or IETF Trust, nor the Chris@69: # names of specific contributors, may be used to endorse or promote Chris@69: # products derived from this software without specific prior written Chris@69: # permission. Chris@69: # Chris@69: # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: Chris@69: rm -f logs_mono.txt logs_mono2.txt Chris@69: rm -f logs_stereo.txt logs_stereo2.txt Chris@69: Chris@69: if [ "$#" -ne "3" ]; then Chris@69: echo "usage: run_vectors.sh " Chris@69: exit 1 Chris@69: fi Chris@69: Chris@69: CMD_PATH=$1 Chris@69: VECTOR_PATH=$2 Chris@69: RATE=$3 Chris@69: Chris@69: : ${OPUS_DEMO:=$CMD_PATH/opus_demo} Chris@69: : ${OPUS_COMPARE:=$CMD_PATH/opus_compare} Chris@69: Chris@69: if [ -d "$VECTOR_PATH" ]; then Chris@69: echo "Test vectors found in $VECTOR_PATH" Chris@69: else Chris@69: echo "No test vectors found" Chris@69: #Don't make the test fail here because the test vectors Chris@69: #will be distributed separately Chris@69: exit 0 Chris@69: fi Chris@69: Chris@69: if [ ! -x "$OPUS_COMPARE" ]; then Chris@69: echo "ERROR: Compare program not found: $OPUS_COMPARE" Chris@69: exit 1 Chris@69: fi Chris@69: Chris@69: if [ -x "$OPUS_DEMO" ]; then Chris@69: echo "Decoding with $OPUS_DEMO" Chris@69: else Chris@69: echo "ERROR: Decoder not found: $OPUS_DEMO" Chris@69: exit 1 Chris@69: fi Chris@69: Chris@69: echo "==============" Chris@69: echo "Testing mono" Chris@69: echo "==============" Chris@69: echo Chris@69: Chris@69: for file in 01 02 03 04 05 06 07 08 09 10 11 12 Chris@69: do Chris@69: if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then Chris@69: echo "Testing testvector$file" Chris@69: else Chris@69: echo "Bitstream file not found: testvector$file.bit" Chris@69: fi Chris@69: if "$OPUS_DEMO" -d "$RATE" 1 "$VECTOR_PATH/testvector$file.bit" tmp.out >> logs_mono.txt 2>&1; then Chris@69: echo "successfully decoded" Chris@69: else Chris@69: echo "ERROR: decoding failed" Chris@69: exit 1 Chris@69: fi Chris@69: "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >> logs_mono.txt 2>&1 Chris@69: float_ret=$? Chris@69: "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out >> logs_mono2.txt 2>&1 Chris@69: float_ret2=$? Chris@69: if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then Chris@69: echo "output matches reference" Chris@69: else Chris@69: echo "ERROR: output does not match reference" Chris@69: exit 1 Chris@69: fi Chris@69: echo Chris@69: done Chris@69: Chris@69: echo "==============" Chris@69: echo Testing stereo Chris@69: echo "==============" Chris@69: echo Chris@69: Chris@69: for file in 01 02 03 04 05 06 07 08 09 10 11 12 Chris@69: do Chris@69: if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then Chris@69: echo "Testing testvector$file" Chris@69: else Chris@69: echo "Bitstream file not found: testvector$file" Chris@69: fi Chris@69: if "$OPUS_DEMO" -d "$RATE" 2 "$VECTOR_PATH/testvector$file.bit" tmp.out >> logs_stereo.txt 2>&1; then Chris@69: echo "successfully decoded" Chris@69: else Chris@69: echo "ERROR: decoding failed" Chris@69: exit 1 Chris@69: fi Chris@69: "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >> logs_stereo.txt 2>&1 Chris@69: float_ret=$? Chris@69: "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out >> logs_stereo2.txt 2>&1 Chris@69: float_ret2=$? Chris@69: if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then Chris@69: echo "output matches reference" Chris@69: else Chris@69: echo "ERROR: output does not match reference" Chris@69: exit 1 Chris@69: fi Chris@69: echo Chris@69: done Chris@69: Chris@69: Chris@69: Chris@69: echo "All tests have passed successfully" Chris@69: mono1=`grep quality logs_mono.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` Chris@69: mono2=`grep quality logs_mono2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` Chris@69: echo $mono1 $mono2 | awk '{if ($2 > $1) $1 = $2; print "Average mono quality is", $1, "%"}' Chris@69: Chris@69: stereo1=`grep quality logs_stereo.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` Chris@69: stereo2=`grep quality logs_stereo2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` Chris@69: echo $stereo1 $stereo2 | awk '{if ($2 > $1) $1 = $2; print "Average stereo quality is", $1, "%"}'