blob: 36e1bd44081e82181155477b096b7dfa1b903d3a [file] [log] [blame]
Josh Coalsonbb7f6b92000-12-10 04:09:52 +00001#!/bin/sh
2
Josh Coalson6b05bc52001-06-08 00:13:21 +00003# FLAC - Free Lossless Audio Codec
Josh Coalsone74bd952007-02-02 06:58:19 +00004# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Josh Coalson6b05bc52001-06-08 00:13:21 +00005#
Josh Coalsone8a76012003-02-07 00:14:32 +00006# This file is part the FLAC project. FLAC is comprised of several
7# components distributed under difference licenses. The codec libraries
8# are distributed under Xiph.Org's BSD-like license (see the file
9# COPYING.Xiph in this distribution). All other programs, libraries, and
10# plugins are distributed under the GPL (see COPYING.GPL). The documentation
11# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
12# FLAC distribution contains at the top the terms under which it may be
13# distributed.
Josh Coalson6b05bc52001-06-08 00:13:21 +000014#
Josh Coalsone8a76012003-02-07 00:14:32 +000015# Since this particular file is relevant to all components of FLAC,
16# it may be distributed under the Xiph.Org license, which is the least
17# restrictive of those mentioned above. See the file COPYING.Xiph in this
18# distribution.
Josh Coalson6b05bc52001-06-08 00:13:21 +000019
Josh Coalson6218b342002-12-12 03:58:18 +000020die ()
21{
22 echo $* 1>&2
23 exit 1
24}
25
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000026if [ x = x"$1" ] ; then
27 BUILD=debug
28else
29 BUILD="$1"
30fi
31
32LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000033export LD_LIBRARY_PATH
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000034PATH=../src/flac:$PATH
35PATH=../src/test_streams:$PATH
36PATH=../obj/$BUILD/bin:$PATH
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000037
Josh Coalson4ac9fdb2006-11-02 01:38:55 +000038if [ x"$FLAC__TEST_LEVEL" = x ] ; then
39 FLAC__TEST_LEVEL=1
40fi
41
Josh Coalson6218b342002-12-12 03:58:18 +000042flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalsonbc869502002-06-14 06:36:16 +000043
Josh Coalson34c1ea82002-12-04 04:57:33 +000044run_flac ()
45{
Josh Coalsonde9091e2006-05-25 02:48:22 +000046 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000047 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_streams.valgrind.log
Josh Coalson80936c52002-12-30 23:31:47 +000048 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_streams.valgrind.log
Josh Coalson34c1ea82002-12-04 04:57:33 +000049 else
50 flac $*
51 fi
52}
53
Josh Coalsonf6237c82001-02-28 23:43:29 +000054echo "Generating streams..."
Josh Coalsond3fe7282002-12-10 06:42:15 +000055if [ ! -f wacky1.wav ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +000056 test_streams || die "ERROR during test_streams"
Josh Coalson9bcf9e82002-08-07 17:07:37 +000057fi
58
Josh Coalson9bcf9e82002-08-07 17:07:37 +000059#
Josh Coalsond3fe7282002-12-10 06:42:15 +000060# single-file test routines
Josh Coalson9bcf9e82002-08-07 17:07:37 +000061#
62
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000063test_file ()
64{
65 name=$1
66 channels=$2
67 bps=$3
68 encode_options="$4"
69
Josh Coalson9b145182002-08-30 05:39:36 +000070 echo -n "$name (--channels=$channels --bps=$bps $encode_options): encode..."
Josh Coalson5ebd6932006-11-17 06:03:18 +000071 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"
Josh Coalson29b4af82001-02-08 22:00:05 +000072 echo "### ENCODE $name #######################################################" >> ./streams.log
73 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000074 $cmd 2>>./streams.log || die "ERROR during encode of $name"
75
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000076 echo -n "decode..."
Josh Coalson439367c2005-02-03 04:20:16 +000077 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac"
Josh Coalson29b4af82001-02-08 22:00:05 +000078 echo "### DECODE $name #######################################################" >> ./streams.log
79 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000080 $cmd 2>>./streams.log || die "ERROR during decode of $name"
81
Josh Coalson29b4af82001-02-08 22:00:05 +000082 ls -1l $name.raw >> ./streams.log
83 ls -1l $name.flac >> ./streams.log
84 ls -1l $name.cmp >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000085
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000086 echo -n "compare..."
Josh Coalson6218b342002-12-12 03:58:18 +000087 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
88
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000089 echo OK
90}
91
Josh Coalsona59ff6f2002-06-10 18:24:51 +000092test_file_piped ()
93{
94 name=$1
95 channels=$2
96 bps=$3
97 encode_options="$4"
98
Josh Coalsond57c8d32002-06-11 06:15:28 +000099 if [ `env | grep -ic '^comspec='` != 0 ] ; then
100 is_win=yes
101 else
102 is_win=no
103 fi
104
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000105 echo -n "$name: encode via pipes..."
Josh Coalsond57c8d32002-06-11 06:15:28 +0000106 if [ $is_win = yes ] ; then
Josh Coalson5ebd6932006-11-17 06:03:18 +0000107 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"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000108 echo "### ENCODE $name #######################################################" >> ./streams.log
109 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000110 $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000111 else
Josh Coalson5ebd6932006-11-17 06:03:18 +0000112 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 -"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000113 echo "### ENCODE $name #######################################################" >> ./streams.log
114 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000115 cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000116 fi
117 echo -n "decode via pipes..."
Josh Coalsond57c8d32002-06-11 06:15:28 +0000118 if [ $is_win = yes ] ; then
Josh Coalson439367c2005-02-03 04:20:16 +0000119 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000120 echo "### DECODE $name #######################################################" >> ./streams.log
121 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000122 $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000123 else
Josh Coalson439367c2005-02-03 04:20:16 +0000124 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000125 echo "### DECODE $name #######################################################" >> ./streams.log
126 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000127 cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000128 fi
129 ls -1l $name.raw >> ./streams.log
130 ls -1l $name.flac >> ./streams.log
131 ls -1l $name.cmp >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000132
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000133 echo -n "compare..."
Josh Coalson6218b342002-12-12 03:58:18 +0000134 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
135
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000136 echo OK
137}
138
Josh Coalsonde9091e2006-05-25 02:48:22 +0000139if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalson9b145182002-08-30 05:39:36 +0000140 max_lpc_order=32
141else
142 max_lpc_order=16
143fi
144
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000145echo "Testing noise through pipes..."
146test_file_piped noise 1 8 "-0"
147
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000148echo "Testing small files..."
Josh Coalsond0edb972006-10-07 06:50:08 +0000149test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
150test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
151test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
152test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000153
Josh Coalson574dc9c2007-01-19 05:33:30 +0000154for bps in 8 16 24 ; do
155 echo "Testing $bps-bit full-scale deflection streams..."
156 for b in 01 02 03 04 05 06 07 ; do
157 test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p"
158 done
Josh Coalson29b4af82001-02-08 22:00:05 +0000159done
Josh Coalsonf6237c82001-02-28 23:43:29 +0000160
Josh Coalsond0418492001-03-27 23:58:23 +0000161echo "Testing 16-bit wasted-bits-per-sample streams..."
162for b in 01 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000163 test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
Josh Coalsond0418492001-03-27 23:58:23 +0000164done
165
Josh Coalson9fb180b2002-08-22 07:26:06 +0000166for bps in 8 16 24 ; do
Josh Coalsonf6237c82001-02-28 23:43:29 +0000167 echo "Testing $bps-bit sine wave streams..."
Josh Coalson9fb180b2002-08-22 07:26:06 +0000168 for b in 00 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000169 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000170 done
171 for b in 01 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000172 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000173 done
174 for b in 02 03 04 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000175 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e"
Josh Coalsonf6237c82001-02-28 23:43:29 +0000176 done
Josh Coalson9fb180b2002-08-22 07:26:06 +0000177 for b in 10 11 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000178 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000179 done
180 for b in 12 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000181 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000182 done
183 for b in 13 14 15 16 17 18 19 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000184 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e"
Josh Coalsonf6237c82001-02-28 23:43:29 +0000185 done
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000186done
187
Josh Coalson94b22e02002-10-11 06:22:30 +0000188echo "Testing blocksize variations..."
189for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
190 for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
191 for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do
192 if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then
Josh Coalson574dc9c2007-01-19 05:33:30 +0000193 test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable"
Josh Coalson94b22e02002-10-11 06:22:30 +0000194 fi
195 done
196 done
197done
198
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000199echo "Testing some frame header variations..."
Josh Coalson9b145182002-08-30 05:39:36 +0000200test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order"
201test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535"
202test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
203test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
204test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
Josh Coalsone2281f32002-09-11 00:31:47 +0000205test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
206test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
207test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
Josh Coalson29b4af82001-02-08 22:00:05 +0000208
209echo "Testing option variations..."
210for f in 00 01 02 03 04 ; do
Josh Coalson94b22e02002-10-11 06:22:30 +0000211 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000212 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
213 for opt in 0 1 2 4 5 6 8 ; do
214 for extras in '' '-p' '-e' ; do
215 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
216 test_file sine16-$f 1 16 "-$opt $extras $disable"
217 fi
218 done
Josh Coalson29b4af82001-02-08 22:00:05 +0000219 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000220 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000221 test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000222 fi
Josh Coalson9b145182002-08-30 05:39:36 +0000223 fi
Josh Coalson29b4af82001-02-08 22:00:05 +0000224 done
225done
Josh Coalson94b22e02002-10-11 06:22:30 +0000226
227for f in 10 11 12 13 14 15 16 17 18 19 ; do
228 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000229 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
230 for opt in 0 1 2 4 5 6 8 ; do
231 for extras in '' '-p' '-e' ; do
232 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
233 test_file sine16-$f 2 16 "-$opt $extras $disable"
234 fi
235 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000236 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000237 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000238 test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000239 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000240 fi
241 done
242done
243
244echo "Testing noise..."
245for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000246 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
247 for channels in 1 2 4 8 ; do
248 if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
249 for bps in 8 16 24 ; do
250 for opt in 0 1 2 3 4 5 6 7 8 ; do
251 for extras in '' '-p' '-e' ; do
252 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
253 for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
254 if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
255 test_file noise $channels $bps "-$opt $extras $blocksize $disable"
256 fi
257 done
258 fi
259 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000260 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000261 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000262 test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000263 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000264 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000265 fi
266 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000267 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000268done