Mercurial > hg > sv-dependency-builds
comparison src/flac-1.2.1/test/test_streams.sh @ 1:05aa0afa9217
Bring in flac, ogg, vorbis
author | Chris Cannam |
---|---|
date | Tue, 19 Mar 2013 17:37:49 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:c7265573341e | 1:05aa0afa9217 |
---|---|
1 #!/bin/sh | |
2 | |
3 # FLAC - Free Lossless Audio Codec | |
4 # Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson | |
5 # | |
6 # 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. | |
14 # | |
15 # 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. | |
19 | |
20 die () | |
21 { | |
22 echo $* 1>&2 | |
23 exit 1 | |
24 } | |
25 | |
26 if [ x = x"$1" ] ; then | |
27 BUILD=debug | |
28 else | |
29 BUILD="$1" | |
30 fi | |
31 | |
32 LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH | |
33 export LD_LIBRARY_PATH | |
34 PATH=../src/flac:$PATH | |
35 PATH=../src/test_streams:$PATH | |
36 PATH=../obj/$BUILD/bin:$PATH | |
37 | |
38 if [ x"$FLAC__TEST_LEVEL" = x ] ; then | |
39 FLAC__TEST_LEVEL=1 | |
40 fi | |
41 | |
42 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" | |
43 | |
44 run_flac () | |
45 { | |
46 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then | |
47 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_streams.valgrind.log | |
48 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 flac $* 4>>test_streams.valgrind.log | |
49 else | |
50 flac $* | |
51 fi | |
52 } | |
53 | |
54 echo "Generating streams..." | |
55 if [ ! -f wacky1.wav ] ; then | |
56 test_streams || die "ERROR during test_streams" | |
57 fi | |
58 | |
59 # | |
60 # single-file test routines | |
61 # | |
62 | |
63 test_file () | |
64 { | |
65 name=$1 | |
66 channels=$2 | |
67 bps=$3 | |
68 encode_options="$4" | |
69 | |
70 echo -n "$name (--channels=$channels --bps=$bps $encode_options): encode..." | |
71 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" | |
72 echo "### ENCODE $name #######################################################" >> ./streams.log | |
73 echo "### cmd=$cmd" >> ./streams.log | |
74 $cmd 2>>./streams.log || die "ERROR during encode of $name" | |
75 | |
76 echo -n "decode..." | |
77 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac" | |
78 echo "### DECODE $name #######################################################" >> ./streams.log | |
79 echo "### cmd=$cmd" >> ./streams.log | |
80 $cmd 2>>./streams.log || die "ERROR during decode of $name" | |
81 | |
82 ls -1l $name.raw >> ./streams.log | |
83 ls -1l $name.flac >> ./streams.log | |
84 ls -1l $name.cmp >> ./streams.log | |
85 | |
86 echo -n "compare..." | |
87 cmp $name.raw $name.cmp || die "ERROR during compare of $name" | |
88 | |
89 echo OK | |
90 } | |
91 | |
92 test_file_piped () | |
93 { | |
94 name=$1 | |
95 channels=$2 | |
96 bps=$3 | |
97 encode_options="$4" | |
98 | |
99 if [ `env | grep -ic '^comspec='` != 0 ] ; then | |
100 is_win=yes | |
101 else | |
102 is_win=no | |
103 fi | |
104 | |
105 echo -n "$name: encode via pipes..." | |
106 if [ $is_win = yes ] ; then | |
107 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" | |
108 echo "### ENCODE $name #######################################################" >> ./streams.log | |
109 echo "### cmd=$cmd" >> ./streams.log | |
110 $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name" | |
111 else | |
112 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 -" | |
113 echo "### ENCODE $name #######################################################" >> ./streams.log | |
114 echo "### cmd=$cmd" >> ./streams.log | |
115 cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name" | |
116 fi | |
117 echo -n "decode via pipes..." | |
118 if [ $is_win = yes ] ; then | |
119 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac" | |
120 echo "### DECODE $name #######################################################" >> ./streams.log | |
121 echo "### cmd=$cmd" >> ./streams.log | |
122 $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name" | |
123 else | |
124 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -" | |
125 echo "### DECODE $name #######################################################" >> ./streams.log | |
126 echo "### cmd=$cmd" >> ./streams.log | |
127 cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name" | |
128 fi | |
129 ls -1l $name.raw >> ./streams.log | |
130 ls -1l $name.flac >> ./streams.log | |
131 ls -1l $name.cmp >> ./streams.log | |
132 | |
133 echo -n "compare..." | |
134 cmp $name.raw $name.cmp || die "ERROR during compare of $name" | |
135 | |
136 echo OK | |
137 } | |
138 | |
139 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then | |
140 max_lpc_order=32 | |
141 else | |
142 max_lpc_order=16 | |
143 fi | |
144 | |
145 echo "Testing noise through pipes..." | |
146 test_file_piped noise 1 8 "-0" | |
147 | |
148 echo "Testing small files..." | |
149 test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p" | |
150 test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p" | |
151 test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p" | |
152 test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p" | |
153 | |
154 for 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 | |
159 done | |
160 | |
161 echo "Testing 16-bit wasted-bits-per-sample streams..." | |
162 for b in 01 ; do | |
163 test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p" | |
164 done | |
165 | |
166 for bps in 8 16 24 ; do | |
167 echo "Testing $bps-bit sine wave streams..." | |
168 for b in 00 ; do | |
169 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000" | |
170 done | |
171 for b in 01 ; do | |
172 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000" | |
173 done | |
174 for b in 02 03 04 ; do | |
175 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e" | |
176 done | |
177 for b in 10 11 ; do | |
178 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000" | |
179 done | |
180 for b in 12 ; do | |
181 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000" | |
182 done | |
183 for b in 13 14 15 16 17 18 19 ; do | |
184 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e" | |
185 done | |
186 done | |
187 | |
188 echo "Testing blocksize variations..." | |
189 for 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 | |
193 test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable" | |
194 fi | |
195 done | |
196 done | |
197 done | |
198 | |
199 echo "Testing some frame header variations..." | |
200 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order" | |
201 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535" | |
202 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9" | |
203 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90" | |
204 test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000" | |
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 | |
209 echo "Testing option variations..." | |
210 for f in 00 01 02 03 04 ; do | |
211 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do | |
212 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 | |
219 done | |
220 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then | |
221 test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" | |
222 fi | |
223 fi | |
224 done | |
225 done | |
226 | |
227 for 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 | |
229 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 | |
236 done | |
237 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then | |
238 test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" | |
239 fi | |
240 fi | |
241 done | |
242 done | |
243 | |
244 echo "Testing noise..." | |
245 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do | |
246 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 | |
260 done | |
261 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then | |
262 test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" | |
263 fi | |
264 done | |
265 fi | |
266 done | |
267 fi | |
268 done |