annotate src/flac-1.2.1/test/test_bins.sh @ 1:05aa0afa9217

Bring in flac, ogg, vorbis
author Chris Cannam
date Tue, 19 Mar 2013 17:37:49 +0000
parents
children
rev   line source
Chris@1 1 #!/bin/sh
Chris@1 2
Chris@1 3 # FLAC - Free Lossless Audio Codec
Chris@1 4 # Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Chris@1 5 #
Chris@1 6 # This file is part the FLAC project. FLAC is comprised of several
Chris@1 7 # components distributed under difference licenses. The codec libraries
Chris@1 8 # are distributed under Xiph.Org's BSD-like license (see the file
Chris@1 9 # COPYING.Xiph in this distribution). All other programs, libraries, and
Chris@1 10 # plugins are distributed under the GPL (see COPYING.GPL). The documentation
Chris@1 11 # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
Chris@1 12 # FLAC distribution contains at the top the terms under which it may be
Chris@1 13 # distributed.
Chris@1 14 #
Chris@1 15 # Since this particular file is relevant to all components of FLAC,
Chris@1 16 # it may be distributed under the Xiph.Org license, which is the least
Chris@1 17 # restrictive of those mentioned above. See the file COPYING.Xiph in this
Chris@1 18 # distribution.
Chris@1 19
Chris@1 20 die ()
Chris@1 21 {
Chris@1 22 echo $* 1>&2
Chris@1 23 exit 1
Chris@1 24 }
Chris@1 25
Chris@1 26 if [ x = x"$1" ] ; then
Chris@1 27 BUILD=debug
Chris@1 28 else
Chris@1 29 BUILD="$1"
Chris@1 30 fi
Chris@1 31
Chris@1 32 LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
Chris@1 33 LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
Chris@1 34 LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
Chris@1 35 LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
Chris@1 36 LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
Chris@1 37 LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
Chris@1 38 LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
Chris@1 39 export LD_LIBRARY_PATH
Chris@1 40 PATH=../src/flac:$PATH
Chris@1 41 PATH=../obj/$BUILD/bin:$PATH
Chris@1 42 BINS_PATH=../../test_files/bins
Chris@1 43
Chris@1 44 if [ x"$FLAC__TEST_LEVEL" = x ] ; then
Chris@1 45 FLAC__TEST_LEVEL=1
Chris@1 46 fi
Chris@1 47
Chris@1 48 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Chris@1 49
Chris@1 50 run_flac ()
Chris@1 51 {
Chris@1 52 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Chris@1 53 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_bins.valgrind.log
Chris@1 54 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 flac $* 4>>test_bins.valgrind.log
Chris@1 55 else
Chris@1 56 flac $*
Chris@1 57 fi
Chris@1 58 }
Chris@1 59
Chris@1 60 test -d ${BINS_PATH} || exit 77
Chris@1 61
Chris@1 62 test_file ()
Chris@1 63 {
Chris@1 64 name=$1
Chris@1 65 channels=$2
Chris@1 66 bps=$3
Chris@1 67 encode_options="$4"
Chris@1 68
Chris@1 69 echo -n "$name.bin (--channels=$channels --bps=$bps $encode_options): encode..."
Chris@1 70 cmd="run_flac --verify --silent --force --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.bin"
Chris@1 71 echo "### ENCODE $name #######################################################" >> ./streams.log
Chris@1 72 echo "### cmd=$cmd" >> ./streams.log
Chris@1 73 $cmd 2>>./streams.log || die "ERROR during encode of $name"
Chris@1 74
Chris@1 75 echo -n "decode..."
Chris@1 76 cmd="run_flac --silent --force --endian=big --sign=signed --decode --force-raw-format $name.flac";
Chris@1 77 echo "### DECODE $name #######################################################" >> ./streams.log
Chris@1 78 echo "### cmd=$cmd" >> ./streams.log
Chris@1 79 $cmd 2>>./streams.log || die "ERROR during decode of $name"
Chris@1 80
Chris@1 81 ls -1l $name.bin >> ./streams.log
Chris@1 82 ls -1l $name.flac >> ./streams.log
Chris@1 83 ls -1l $name.raw >> ./streams.log
Chris@1 84
Chris@1 85 echo -n "compare..."
Chris@1 86 cmp $name.bin $name.raw || die "ERROR during compare of $name"
Chris@1 87
Chris@1 88 echo OK
Chris@1 89 }
Chris@1 90
Chris@1 91 echo "Testing bins..."
Chris@1 92 for f in b00 b01 b02 b03 b04 ; do
Chris@1 93 binfile=$BINS_PATH/$f
Chris@1 94 if [ -f $binfile.bin ] ; then
Chris@1 95 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Chris@1 96 for channels in 1 2 4 8 ; do
Chris@1 97 for bps in 8 16 24 ; do
Chris@1 98 for opt in 0 1 2 4 5 6 8 ; do
Chris@1 99 for extras in '' '-p' '-e' ; do
Chris@1 100 for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
Chris@1 101 test_file $binfile $channels $bps "-$opt $extras $blocksize $disable"
Chris@1 102 done
Chris@1 103 done
Chris@1 104 done
Chris@1 105 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Chris@1 106 test_file $binfile $channels $bps "--lax -b 16384 -m -r 8 -l 32 -e -p $disable"
Chris@1 107 fi
Chris@1 108 done
Chris@1 109 done
Chris@1 110 done
Chris@1 111 else
Chris@1 112 echo "$binfile not found, skipping."
Chris@1 113 fi
Chris@1 114 done