3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001-2009 Josh Coalson
5 # Copyright (C) 2011-2013 Xiph.Org Foundation
7 # This file is part the FLAC project. FLAC is comprised of several
8 # components distributed under difference licenses. The codec libraries
9 # are distributed under Xiph.Org's BSD-like license (see the file
10 # COPYING.Xiph in this distribution). All other programs, libraries, and
11 # plugins are distributed under the GPL (see COPYING.GPL). The documentation
12 # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
13 # FLAC distribution contains at the top the terms under which it may be
16 # Since this particular file is relevant to all components of FLAC,
17 # it may be distributed under the Xiph.Org license, which is the least
18 # restrictive of those mentioned above. See the file COPYING.Xiph in this
27 if [ x = x"$1" ] ; then
33 LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
34 export LD_LIBRARY_PATH
35 export MALLOC_CHECK_=3
36 export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
37 PATH=../src/flac:$PATH
38 PATH=../src/test_streams:$PATH
39 PATH=../objs/$BUILD/bin:$PATH
41 if [ x"$FLAC__TEST_LEVEL" = x ] ; then
45 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
49 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
50 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_streams.valgrind.log
51 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac $* 4>>test_streams.valgrind.log
57 echo "Generating streams..."
58 if [ ! -f wacky1.wav ] ; then
59 test_streams || die "ERROR during test_streams"
63 # single-file test routines
73 echo -n "$name (--channels=$channels --bps=$bps $encode_options): encode..."
74 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.raw"
75 echo "### ENCODE $name #######################################################" >> ./streams.log
76 echo "### cmd=$cmd" >> ./streams.log
77 $cmd 2>>./streams.log || die "ERROR during encode of $name"
80 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac"
81 echo "### DECODE $name #######################################################" >> ./streams.log
82 echo "### cmd=$cmd" >> ./streams.log
83 $cmd 2>>./streams.log || die "ERROR during decode of $name"
85 ls -1l $name.raw >> ./streams.log
86 ls -1l $name.flac >> ./streams.log
87 ls -1l $name.cmp >> ./streams.log
90 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
102 if [ `env | grep -ic '^comspec='` != 0 ] ; then
108 echo -n "$name: encode via pipes..."
109 if [ $is_win = yes ] ; then
110 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout $name.raw"
111 echo "### ENCODE $name #######################################################" >> ./streams.log
112 echo "### cmd=$cmd" >> ./streams.log
113 $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
115 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout -"
116 echo "### ENCODE $name #######################################################" >> ./streams.log
117 echo "### cmd=$cmd" >> ./streams.log
118 cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
120 echo -n "decode via pipes..."
121 if [ $is_win = yes ] ; then
122 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac"
123 echo "### DECODE $name #######################################################" >> ./streams.log
124 echo "### cmd=$cmd" >> ./streams.log
125 $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
127 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -"
128 echo "### DECODE $name #######################################################" >> ./streams.log
129 echo "### cmd=$cmd" >> ./streams.log
130 cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
132 ls -1l $name.raw >> ./streams.log
133 ls -1l $name.flac >> ./streams.log
134 ls -1l $name.cmp >> ./streams.log
137 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
142 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
148 echo "Testing noise through pipes..."
149 test_file_piped noise 1 8 "-0"
151 echo "Testing small files..."
152 test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
153 test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
154 test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
155 test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
157 for bps in 8 16 24 ; do
158 echo "Testing $bps-bit full-scale deflection streams..."
159 for b in 01 02 03 04 05 06 07 ; do
160 test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p"
164 echo "Testing 16-bit wasted-bits-per-sample streams..."
166 test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
169 for bps in 8 16 24 ; do
170 echo "Testing $bps-bit sine wave streams..."
172 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
175 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
177 for b in 02 03 04 ; do
178 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e"
181 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
184 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
186 for b in 13 14 15 16 17 18 19 ; do
187 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e"
191 echo "Testing blocksize variations..."
192 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
193 for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
194 for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do
195 if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then
196 test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable"
202 echo "Testing some frame header variations..."
203 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order"
204 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535"
205 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
206 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
207 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
208 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
209 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
210 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
212 echo "Testing option variations..."
213 for f in 00 01 02 03 04 ; do
214 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
215 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
216 for opt in 0 1 2 4 5 6 8 ; do
217 for extras in '' '-p' '-e' ; do
218 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
219 test_file sine16-$f 1 16 "-$opt $extras $disable"
223 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
224 test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
230 for f in 10 11 12 13 14 15 16 17 18 19 ; do
231 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
232 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
233 for opt in 0 1 2 4 5 6 8 ; do
234 for extras in '' '-p' '-e' ; do
235 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
236 test_file sine16-$f 2 16 "-$opt $extras $disable"
240 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
241 test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
247 echo "Testing noise..."
248 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
249 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
250 for channels in 1 2 4 8 ; do
251 if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
252 for bps in 8 16 24 ; do
253 for opt in 0 1 2 3 4 5 6 7 8 ; do
254 for extras in '' '-p' '-e' ; do
255 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
256 for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
257 if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
258 test_file noise $channels $bps "-$opt $extras $blocksize $disable"
264 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
265 test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"