3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001,2002,2003,2004 Josh Coalson
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
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
26 LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
27 export LD_LIBRARY_PATH
28 PATH=../src/flac:../src/metaflac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH
30 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
34 if [ x"$FLAC__VALGRIND" = xyes ] ; then
35 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
41 echo "Checking for --ogg support in flac..."
42 if flac --ogg --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
44 echo "flac --ogg works"
47 echo "flac --ogg doesn't work"
51 echo "Generating streams..."
52 if [ ! -f wacky1.wav ] ; then
53 test_streams || die "ERROR during test_streams"
56 ############################################################################
57 # test that flac doesn't automatically overwrite files unless -f is used
58 ############################################################################
60 echo "Try encoding to a file that exists; should fail"
61 cp wacky1.wav exist.wav
63 if run_flac --totally-silent -0 exist.wav ; then
64 die "ERROR: it should have failed but didn't"
66 echo "OK, it failed as it should"
69 echo "Try encoding with -f to a file that exists; should succeed"
70 if run_flac --totally-silent -0 --force exist.wav ; then
71 echo "OK, it succeeded as it should"
73 die "ERROR: it should have succeeded but didn't"
76 echo "Try decoding to a file that exists; should fail"
77 if run_flac --totally-silent -d exist.flac ; then
78 die "ERROR: it should have failed but didn't"
80 echo "OK, it failed as it should"
83 echo "Try decoding with -f to a file that exists; should succeed"
84 if run_flac --totally-silent -d -f exist.flac ; then
85 echo "OK, it succeeded as it should"
87 die "ERROR: it should have succeeded but didn't"
90 rm -f exist.wav exist.flac
92 ############################################################################
93 # basic 'round-trip' tests of various kinds of streams
94 ############################################################################
99 channels=`echo $f | awk -F- '{print $2}'`
100 bytes_per_sample=`echo $f | awk -F- '{print $3}'`
101 bps=`expr $bytes_per_sample '*' 8`
102 echo -n "round-trip test ($f) encode... "
103 run_flac --silent --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $f -o rt.flac || die "ERROR"
105 run_flac --silent --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
106 echo -n "compare... "
107 cmp $f rt.raw || die "ERROR: file mismatch"
115 echo -n "round-trip test ($f) encode... "
116 run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
118 run_flac --silent --force --decode -o rt.wav rt.flac || die "ERROR"
119 echo -n "compare... "
120 cmp $f rt.wav || die "ERROR: file mismatch"
128 echo -n "round-trip test ($f) encode... "
129 run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
131 run_flac --silent --force --decode -o rt.aiff rt.flac || die "ERROR"
132 echo -n "compare... "
133 cmp $f rt.aiff || die "ERROR: file mismatch"
135 rm -f rt.flac rt.aiff
138 for f in rt-*.raw ; do
141 for f in rt-*.wav ; do
144 for f in rt-*.aiff ; do
148 ############################################################################
149 # test --skip and --until
150 ############################################################################
153 # first make some chopped-up raw files
155 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
156 dddie="die ERROR: creating files for --skip/--until tests"
157 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
158 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
159 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
160 dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
161 dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
162 dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
163 dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
164 dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
165 dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
166 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
167 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
168 dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
169 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
170 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
171 dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
172 dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
174 wav_eopt="--silent --force --verify --lax"
175 wav_dopt="--silent --force --decode"
177 raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
178 raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
181 # convert them to WAVE and AIFF files
185 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to WAVE"
186 run_flac $wav_dopt $1.flac || die "ERROR converting $1.raw to WAVE"
189 convert_to_wav 50c.skip10
190 convert_to_wav 50c.skip11
191 convert_to_wav 50c.skip20
192 convert_to_wav 50c.skip30
193 convert_to_wav 50c.skip40
194 convert_to_wav 50c.until10
195 convert_to_wav 50c.until20
196 convert_to_wav 50c.until30
197 convert_to_wav 50c.until39
198 convert_to_wav 50c.until40
199 convert_to_wav 50c.skip10.until30
200 convert_to_wav 50c.skip10.until39
201 convert_to_wav 50c.skip10.until40
202 convert_to_wav 50c.skip20.until30
203 convert_to_wav 50c.skip20.until40
207 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to AIFF"
208 run_flac $wav_dopt $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
211 convert_to_aiff 50c.skip10
212 convert_to_aiff 50c.skip11
213 convert_to_aiff 50c.skip20
214 convert_to_aiff 50c.skip30
215 convert_to_aiff 50c.skip40
216 convert_to_aiff 50c.until10
217 convert_to_aiff 50c.until20
218 convert_to_aiff 50c.until30
219 convert_to_aiff 50c.until39
220 convert_to_aiff 50c.until40
221 convert_to_aiff 50c.skip10.until30
222 convert_to_aiff 50c.skip10.until39
223 convert_to_aiff 50c.skip10.until40
224 convert_to_aiff 50c.skip20.until30
225 convert_to_aiff 50c.skip20.until40
232 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
234 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
236 if [ $in_fmt = raw ] ; then
244 if [ $out_fmt = ogg ] ; then
249 # test --skip when encoding
252 desc="($in_fmt<->$out_fmt)"
254 echo -n "testing --skip=# (encode) $desc... "
255 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
256 run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
257 cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
258 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
261 echo -n "testing --skip=mm:ss (encode) $desc... "
262 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
263 run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
264 cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
265 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
268 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
269 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
270 run_flac $dopt -o z50c.skip0:01.1001.$in_fmt z50c.skip0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
271 cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
272 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
276 # test --skip when decoding
279 echo -n "testing --skip=# (decode) $desc... "
280 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
281 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
282 cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
283 rm -f z50c.skip10.$in_fmt
286 echo -n "testing --skip=mm:ss (decode) $desc... "
287 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
288 cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
289 rm -f z50c.skip0:01.$in_fmt
292 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
293 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
294 cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
295 rm -f z50c.skip0:01.1001.$in_fmt
301 # test --until when encoding
304 echo -n "testing --until=# (encode) $desc... "
305 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
306 run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
307 cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
308 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
311 echo -n "testing --until=mm:ss (encode) $desc... "
312 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
313 run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
314 cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
315 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
318 echo -n "testing --until=mm:ss.sss (encode) $desc... "
319 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
320 run_flac $dopt -o z50c.until0:03.9001.$in_fmt z50c.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
321 cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
322 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
325 echo -n "testing --until=-# (encode) $desc... "
326 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
327 run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
328 cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
329 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
332 echo -n "testing --until=-mm:ss (encode) $desc... "
333 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
334 run_flac $dopt -o z50c.until-0:01.$in_fmt z50c.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
335 cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
336 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
339 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
340 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
341 run_flac $dopt -o z50c.until-0:01.1001.$in_fmt z50c.until-0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
342 cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
343 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
347 # test --until when decoding
350 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
352 echo -n "testing --until=# (decode) $desc... "
353 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
354 cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
355 rm -f z50c.until40.$in_fmt
358 echo -n "testing --until=mm:ss (decode) $desc... "
359 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
360 cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
361 rm -f z50c.until0:04.$in_fmt
364 echo -n "testing --until=mm:ss.sss (decode) $desc... "
365 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
366 cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
367 rm -f z50c.until0:03.9001.$in_fmt
370 echo -n "testing --until=-# (decode) $desc... "
371 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
372 cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
373 rm -f z50c.until-10.$in_fmt
376 echo -n "testing --until=-mm:ss (decode) $desc... "
377 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
378 cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
379 rm -f z50c.until-0:01.$in_fmt
382 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
383 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
384 cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
385 rm -f z50c.until-0:01.1001.$in_fmt
391 # test --skip and --until when encoding
394 echo -n "testing --skip=10 --until=# (encode) $desc... "
395 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
396 run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
397 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
398 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
401 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
402 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
403 run_flac $dopt -o z50c.skip10.until0:04.$in_fmt z50c.skip10.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
404 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
405 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
408 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
409 run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
410 run_flac $dopt -o z50c.skip10.until0:03.9001.$in_fmt z50c.skip10.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
411 cmp 50c.skip10.until39.$in_fmt z50c.skip10.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) $desc"
412 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
415 echo -n "testing --skip=10 --until=+# (encode) $desc... "
416 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
417 run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
418 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
419 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
422 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
423 run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0:03.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
424 run_flac $dopt -o z50c.skip10.until+0:03.$in_fmt z50c.skip10.until+0:03.$out_fmt || die "ERROR decoding FLAC file $desc"
425 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until+0:03.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) $desc"
426 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
429 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
430 run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0:02.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
431 run_flac $dopt -o z50c.skip10.until+0:02.9001.$in_fmt z50c.skip10.until+0:02.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
432 cmp 50c.skip10.until39.$in_fmt z50c.skip10.until+0:02.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode) $desc"
433 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
436 echo -n "testing --skip=10 --until=-# (encode) $desc... "
437 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
438 run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
439 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
440 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
443 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
444 run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
445 run_flac $dopt -o z50c.skip10.until-0:01.$in_fmt z50c.skip10.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
446 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-0:01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) $desc"
447 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
450 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
451 run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
452 run_flac $dopt -o z50c.skip10.until-0:01.1001.$in_fmt z50c.skip10.until-0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
453 cmp 50c.skip10.until39.$in_fmt z50c.skip10.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode) $desc"
454 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
458 # test --skip and --until when decoding
461 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
463 echo -n "testing --skip=10 --until=# (decode) $desc... "
464 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
465 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
466 rm -f z50c.skip10.until40.$in_fmt
469 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
470 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
471 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
472 rm -f z50c.skip10.until0:04.$in_fmt
475 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
476 run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
477 cmp 50c.skip10.until39.$in_fmt z50c.skip10.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) $desc"
478 rm -f z50c.skip10.until0:03.9001.$in_fmt
481 echo -n "testing --skip=10 --until=-# (decode) $desc... "
482 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
483 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
484 rm -f z50c.skip10.until-10.$in_fmt
487 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
488 run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
489 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-0:01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) $desc"
490 rm -f z50c.skip10.until-0:01.$in_fmt
493 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
494 run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
495 cmp 50c.skip10.until39.$in_fmt z50c.skip10.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode) $desc"
496 rm -f z50c.skip10.until-0:01.1001.$in_fmt
502 test_skip_until raw flac
503 test_skip_until wav flac
504 test_skip_until aiff flac
506 if [ $has_ogg = "yes" ] ; then
507 test_skip_until raw ogg
508 test_skip_until wav ogg
509 test_skip_until aiff ogg
512 echo "Testing seek extremes:"
514 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 noise.raw || die "ERROR generating FLAC file"
516 total_samples=`metaflac --show-total-samples noise.flac`
517 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
519 echo -n "Testing --skip=0... "
520 run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
523 for delta in 2 1 ; do
524 n=`expr $total_samples - $delta`
525 echo -n "Testing --skip=$n... "
526 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
533 ############################################################################
535 ############################################################################
538 # create the cue sheet
541 cat > $cuesheet << EOF
542 CATALOG 1234567890123
559 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
561 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
563 if [ $in_fmt = raw ] ; then
571 if [ $out_fmt = ogg ] ; then
575 desc="($in_fmt<->$out_fmt)"
578 # for this we need just need just one FLAC file; --cue only works while decoding
580 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
582 # To make it easy to translate from cue point to sample numbers, the
583 # file has a sample rate of 10 Hz and a cuesheet like so:
585 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
586 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
587 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
588 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
589 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
591 echo -n "testing --cue=- $desc... "
592 run_flac $dopt -o z50c.cue.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
593 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
594 rm -f z50c.cue.$in_fmt
597 echo -n "testing --cue=1.0 $desc... "
598 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
599 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
600 rm -f z50c.cue.$in_fmt
603 echo -n "testing --cue=1.0- $desc... "
604 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
605 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
606 rm -f z50c.cue.$in_fmt
609 echo -n "testing --cue=1.1 $desc... "
610 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
611 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
612 rm -f z50c.cue.$in_fmt
615 echo -n "testing --cue=1.1- $desc... "
616 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
617 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
618 rm -f z50c.cue.$in_fmt
621 echo -n "testing --cue=1.2 $desc... "
622 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
623 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
624 rm -f z50c.cue.$in_fmt
627 echo -n "testing --cue=1.2- $desc... "
628 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
629 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
630 rm -f z50c.cue.$in_fmt
633 echo -n "testing --cue=1.4 $desc... "
634 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
635 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
636 rm -f z50c.cue.$in_fmt
639 echo -n "testing --cue=1.4- $desc... "
640 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
641 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
642 rm -f z50c.cue.$in_fmt
645 echo -n "testing --cue=-5.0 $desc... "
646 run_flac $dopt -o z50c.cue.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
647 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
648 rm -f z50c.cue.$in_fmt
651 echo -n "testing --cue=-4.1 $desc... "
652 run_flac $dopt -o z50c.cue.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
653 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
654 rm -f z50c.cue.$in_fmt
657 echo -n "testing --cue=-3.1 $desc... "
658 run_flac $dopt -o z50c.cue.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
659 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
660 rm -f z50c.cue.$in_fmt
663 echo -n "testing --cue=-1.4 $desc... "
664 run_flac $dopt -o z50c.cue.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
665 cmp 50c.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
666 rm -f z50c.cue.$in_fmt
669 echo -n "testing --cue=1.0-5.0 $desc... "
670 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
671 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
672 rm -f z50c.cue.$in_fmt
675 echo -n "testing --cue=1.1-5.0 $desc... "
676 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
677 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
678 rm -f z50c.cue.$in_fmt
681 echo -n "testing --cue=1.2-4.1 $desc... "
682 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
683 cmp 50c.skip10.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
684 rm -f z50c.cue.$in_fmt
687 echo -n "testing --cue=1.4-2.0 $desc... "
688 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
689 cmp 50c.skip20.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
690 rm -f z50c.cue.$in_fmt
693 rm -f z50c.cue.$out_fmt
700 if [ $has_ogg = "yes" ] ; then
706 ############################################################################
707 # test 'fixup' code that happens when a FLAC file with total_samples == 0
708 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
709 # decoder go back and fix up the chunk headers
710 ############################################################################
712 echo -n "WAVE fixup test... "
713 echo -n "prepare... "
714 convert_to_wav noise || die "ERROR creating reference WAVE"
716 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
718 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
719 echo -n "compare... "
720 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
722 rm -f noise.wav fixup.wav fixup.flac
724 echo -n "AIFF fixup test... "
725 echo -n "prepare... "
726 convert_to_aiff noise || die "ERROR creating reference AIFF"
728 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
730 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
731 echo -n "compare... "
732 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
734 rm -f noise.aiff fixup.aiff fixup.flac
737 ############################################################################
739 ############################################################################
741 echo "Generating multiple input files from noise..."
742 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw || die "ERROR generating FLAC file"
743 run_flac --decode --force --silent noise.flac || die "ERROR generating WAVE file"
745 mv noise.wav file0.wav
746 cp file0.wav file1.wav
747 cp file1.wav file2.wav
755 if [ $streamtype = ogg ] ; then
757 encode_options="$encode_options --ogg"
762 if [ $sector_align = sector_align ] ; then
763 encode_options="$encode_options --sector-align"
766 run_flac --force $encode_options file0.wav file1.wav file2.wav || die "ERROR"
768 mv file$n.$suffix file${n}x.$suffix
770 run_flac --force --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
771 if [ $sector_align != sector_align ] ; then
773 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
777 rm -f file${n}x.$suffix file${n}x.wav
781 echo "Testing multiple files without verify..."
782 test_multifile flac no_sector_align ""
784 echo "Testing multiple files with verify..."
785 test_multifile flac no_sector_align "--verify"
787 echo "Testing multiple files with --sector-align, without verify..."
788 test_multifile flac sector_align ""
790 echo "Testing multiple files with --sector-align, with verify..."
791 test_multifile flac sector_align "--verify"
793 if [ $has_ogg = "yes" ] ; then
794 echo "Testing multiple files with --ogg, without verify..."
795 test_multifile ogg no_sector_align ""
797 echo "Testing multiple files with --ogg, with verify..."
798 test_multifile ogg no_sector_align "--verify"
800 echo "Testing multiple files with --ogg and --sector-align, without verify..."
801 test_multifile ogg sector_align ""
803 echo "Testing multiple files with --ogg and --sector-align, with verify..."
804 test_multifile sector_align ogg "--verify"
806 echo "Testing multiple files with --ogg and --serial-number, with verify..."
807 test_multifile ogg no_sector_align "--serial-number=321 --verify"