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
43 if [ x"$FLAC__VALGRIND" = xyes ] ; then
44 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_metaflac.valgrind.log
50 if [ `env | grep -ic '^comspec='` != 0 ] ; then
56 echo "Checking for --ogg support in flac..."
57 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
59 echo "flac --ogg works"
62 echo "flac --ogg doesn't work"
66 echo "Generating streams..."
67 if [ ! -f wacky1.wav ] ; then
68 test_streams || die "ERROR during test_streams"
71 ############################################################################
72 # test that flac doesn't automatically overwrite files unless -f is used
73 ############################################################################
75 echo "Try encoding to a file that exists; should fail"
76 cp wacky1.wav exist.wav
78 if run_flac --totally-silent -0 exist.wav ; then
79 die "ERROR: it should have failed but didn't"
81 echo "OK, it failed as it should"
84 echo "Try encoding with -f to a file that exists; should succeed"
85 if run_flac --totally-silent -0 --force exist.wav ; then
86 echo "OK, it succeeded as it should"
88 die "ERROR: it should have succeeded but didn't"
91 echo "Try decoding to a file that exists; should fail"
92 if run_flac --totally-silent -d exist.flac ; then
93 die "ERROR: it should have failed but didn't"
95 echo "OK, it failed as it should"
98 echo "Try decoding with -f to a file that exists; should succeed"
99 if run_flac --totally-silent -d -f exist.flac ; then
100 echo "OK, it succeeded as it should"
102 die "ERROR: it should have succeeded but didn't"
105 rm -f exist.wav exist.flac
107 ############################################################################
108 # basic 'round-trip' tests of various kinds of streams
109 ############################################################################
114 channels=`echo $f | awk -F- '{print $2}'`
115 bytes_per_sample=`echo $f | awk -F- '{print $3}'`
116 bps=`expr $bytes_per_sample '*' 8`
117 echo -n "round-trip test ($f) encode... "
118 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"
120 run_flac --silent --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
121 echo -n "compare... "
122 cmp $f rt.raw || die "ERROR: file mismatch"
130 echo -n "round-trip test ($f) encode... "
131 run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
133 run_flac --silent --force --decode -o rt.wav rt.flac || die "ERROR"
134 echo -n "compare... "
135 cmp $f rt.wav || die "ERROR: file mismatch"
143 echo -n "round-trip test ($f) encode... "
144 run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
146 run_flac --silent --force --decode -o rt.aiff rt.flac || die "ERROR"
147 echo -n "compare... "
148 cmp $f rt.aiff || die "ERROR: file mismatch"
150 rm -f rt.flac rt.aiff
153 for f in rt-*.raw ; do
156 for f in rt-*.wav ; do
159 for f in rt-*.aiff ; do
163 ############################################################################
164 # test --skip and --until
165 ############################################################################
168 # first make some chopped-up raw files
170 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
171 dddie="die ERROR: creating files for --skip/--until tests"
172 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
173 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
174 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
175 dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
176 dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
177 dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
178 dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
179 dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
180 dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
181 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
182 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
183 dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
184 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
185 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
186 dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
187 dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
189 wav_eopt="--silent --force --verify --lax"
190 wav_dopt="--silent --force --decode"
192 raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
193 raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
196 # convert them to WAVE and AIFF files
200 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to WAVE"
201 run_flac $wav_dopt $1.flac || die "ERROR converting $1.raw to WAVE"
204 convert_to_wav 50c.skip10
205 convert_to_wav 50c.skip11
206 convert_to_wav 50c.skip20
207 convert_to_wav 50c.skip30
208 convert_to_wav 50c.skip40
209 convert_to_wav 50c.until10
210 convert_to_wav 50c.until20
211 convert_to_wav 50c.until30
212 convert_to_wav 50c.until39
213 convert_to_wav 50c.until40
214 convert_to_wav 50c.skip10.until30
215 convert_to_wav 50c.skip10.until39
216 convert_to_wav 50c.skip10.until40
217 convert_to_wav 50c.skip20.until30
218 convert_to_wav 50c.skip20.until40
222 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to AIFF"
223 run_flac $wav_dopt $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
226 convert_to_aiff 50c.skip10
227 convert_to_aiff 50c.skip11
228 convert_to_aiff 50c.skip20
229 convert_to_aiff 50c.skip30
230 convert_to_aiff 50c.skip40
231 convert_to_aiff 50c.until10
232 convert_to_aiff 50c.until20
233 convert_to_aiff 50c.until30
234 convert_to_aiff 50c.until39
235 convert_to_aiff 50c.until40
236 convert_to_aiff 50c.skip10.until30
237 convert_to_aiff 50c.skip10.until39
238 convert_to_aiff 50c.skip10.until40
239 convert_to_aiff 50c.skip20.until30
240 convert_to_aiff 50c.skip20.until40
247 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
249 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
251 if [ $in_fmt = raw ] ; then
259 if [ $out_fmt = ogg ] ; then
264 # test --skip when encoding
267 desc="($in_fmt<->$out_fmt)"
269 echo -n "testing --skip=# (encode) $desc... "
270 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
271 run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
272 cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
273 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
276 echo -n "testing --skip=mm:ss (encode) $desc... "
277 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
278 run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
279 cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
280 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
283 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
284 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
285 run_flac $dopt -o z50c.skip0:01.1001.$in_fmt z50c.skip0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
286 cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
287 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
291 # test --skip when decoding
294 echo -n "testing --skip=# (decode) $desc... "
295 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
296 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
297 cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
298 rm -f z50c.skip10.$in_fmt
301 echo -n "testing --skip=mm:ss (decode) $desc... "
302 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
303 cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
304 rm -f z50c.skip0:01.$in_fmt
307 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
308 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
309 cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
310 rm -f z50c.skip0:01.1001.$in_fmt
316 # test --until when encoding
319 echo -n "testing --until=# (encode) $desc... "
320 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
321 run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
322 cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
323 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
326 echo -n "testing --until=mm:ss (encode) $desc... "
327 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
328 run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
329 cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
330 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
333 echo -n "testing --until=mm:ss.sss (encode) $desc... "
334 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
335 run_flac $dopt -o z50c.until0:03.9001.$in_fmt z50c.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
336 cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
337 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
340 echo -n "testing --until=-# (encode) $desc... "
341 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
342 run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
343 cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
344 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
347 echo -n "testing --until=-mm:ss (encode) $desc... "
348 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
349 run_flac $dopt -o z50c.until-0:01.$in_fmt z50c.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
350 cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
351 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
354 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
355 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
356 run_flac $dopt -o z50c.until-0:01.1001.$in_fmt z50c.until-0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
357 cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
358 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
362 # test --until when decoding
365 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
367 echo -n "testing --until=# (decode) $desc... "
368 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
369 cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
370 rm -f z50c.until40.$in_fmt
373 echo -n "testing --until=mm:ss (decode) $desc... "
374 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
375 cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
376 rm -f z50c.until0:04.$in_fmt
379 echo -n "testing --until=mm:ss.sss (decode) $desc... "
380 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
381 cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
382 rm -f z50c.until0:03.9001.$in_fmt
385 echo -n "testing --until=-# (decode) $desc... "
386 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
387 cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
388 rm -f z50c.until-10.$in_fmt
391 echo -n "testing --until=-mm:ss (decode) $desc... "
392 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
393 cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
394 rm -f z50c.until-0:01.$in_fmt
397 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
398 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
399 cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
400 rm -f z50c.until-0:01.1001.$in_fmt
406 # test --skip and --until when encoding
409 echo -n "testing --skip=10 --until=# (encode) $desc... "
410 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
411 run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
412 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
413 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
416 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
417 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
418 run_flac $dopt -o z50c.skip10.until0:04.$in_fmt z50c.skip10.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
419 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
420 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
423 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
424 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"
425 run_flac $dopt -o z50c.skip10.until0:03.9001.$in_fmt z50c.skip10.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
426 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"
427 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
430 echo -n "testing --skip=10 --until=+# (encode) $desc... "
431 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
432 run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
433 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
434 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
437 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
438 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"
439 run_flac $dopt -o z50c.skip10.until+0:03.$in_fmt z50c.skip10.until+0:03.$out_fmt || die "ERROR decoding FLAC file $desc"
440 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"
441 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
444 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
445 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"
446 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"
447 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"
448 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
451 echo -n "testing --skip=10 --until=-# (encode) $desc... "
452 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
453 run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
454 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
455 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
458 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
459 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"
460 run_flac $dopt -o z50c.skip10.until-0:01.$in_fmt z50c.skip10.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
461 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"
462 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
465 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
466 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"
467 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"
468 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"
469 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
473 # test --skip and --until when decoding
476 run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
478 echo -n "testing --skip=10 --until=# (decode) $desc... "
479 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
480 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
481 rm -f z50c.skip10.until40.$in_fmt
484 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
485 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
486 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
487 rm -f z50c.skip10.until0:04.$in_fmt
490 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
491 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"
492 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"
493 rm -f z50c.skip10.until0:03.9001.$in_fmt
496 echo -n "testing --skip=10 --until=-# (decode) $desc... "
497 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
498 cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
499 rm -f z50c.skip10.until-10.$in_fmt
502 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
503 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"
504 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"
505 rm -f z50c.skip10.until-0:01.$in_fmt
508 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
509 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"
510 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"
511 rm -f z50c.skip10.until-0:01.1001.$in_fmt
517 test_skip_until raw flac
518 test_skip_until wav flac
519 test_skip_until aiff flac
521 if [ $has_ogg = "yes" ] ; then
522 test_skip_until raw ogg
523 test_skip_until wav ogg
524 test_skip_until aiff ogg
527 echo "testing seek extremes:"
529 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"
531 if [ $is_win = no ] ; then
532 total_samples=`run_metaflac --show-total-samples noise.flac`
533 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
535 # some flavors of cygwin don't seem to treat the \x0d as a word
536 # separator, so we hard code it. we'll just have to fix it later
537 # if we change the way noise.flac is made.
541 echo -n "testing --skip=0... "
542 run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
545 for delta in 2 1 ; do
546 n=`expr $total_samples - $delta`
547 echo -n "testing --skip=$n... "
548 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
555 ############################################################################
557 ############################################################################
560 # create the cue sheet
563 cat > $cuesheet << EOF
564 CATALOG 1234567890123
581 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
583 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
585 if [ $in_fmt = raw ] ; then
593 if [ $out_fmt = ogg ] ; then
597 desc="($in_fmt<->$out_fmt)"
600 # for this we need just need just one FLAC file; --cue only works while decoding
602 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
604 # To make it easy to translate from cue point to sample numbers, the
605 # file has a sample rate of 10 Hz and a cuesheet like so:
607 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
608 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
609 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
610 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
611 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
613 echo -n "testing --cue=- $desc... "
614 run_flac $dopt -o z50c.cue.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
615 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
616 rm -f z50c.cue.$in_fmt
619 echo -n "testing --cue=1.0 $desc... "
620 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
621 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
622 rm -f z50c.cue.$in_fmt
625 echo -n "testing --cue=1.0- $desc... "
626 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
627 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
628 rm -f z50c.cue.$in_fmt
631 echo -n "testing --cue=1.1 $desc... "
632 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
633 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
634 rm -f z50c.cue.$in_fmt
637 echo -n "testing --cue=1.1- $desc... "
638 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
639 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
640 rm -f z50c.cue.$in_fmt
643 echo -n "testing --cue=1.2 $desc... "
644 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
645 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
646 rm -f z50c.cue.$in_fmt
649 echo -n "testing --cue=1.2- $desc... "
650 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
651 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
652 rm -f z50c.cue.$in_fmt
655 echo -n "testing --cue=1.4 $desc... "
656 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
657 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
658 rm -f z50c.cue.$in_fmt
661 echo -n "testing --cue=1.4- $desc... "
662 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
663 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
664 rm -f z50c.cue.$in_fmt
667 echo -n "testing --cue=-5.0 $desc... "
668 run_flac $dopt -o z50c.cue.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
669 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
670 rm -f z50c.cue.$in_fmt
673 echo -n "testing --cue=-4.1 $desc... "
674 run_flac $dopt -o z50c.cue.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
675 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
676 rm -f z50c.cue.$in_fmt
679 echo -n "testing --cue=-3.1 $desc... "
680 run_flac $dopt -o z50c.cue.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
681 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
682 rm -f z50c.cue.$in_fmt
685 echo -n "testing --cue=-1.4 $desc... "
686 run_flac $dopt -o z50c.cue.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
687 cmp 50c.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
688 rm -f z50c.cue.$in_fmt
691 echo -n "testing --cue=1.0-5.0 $desc... "
692 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
693 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
694 rm -f z50c.cue.$in_fmt
697 echo -n "testing --cue=1.1-5.0 $desc... "
698 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
699 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
700 rm -f z50c.cue.$in_fmt
703 echo -n "testing --cue=1.2-4.1 $desc... "
704 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
705 cmp 50c.skip10.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
706 rm -f z50c.cue.$in_fmt
709 echo -n "testing --cue=1.4-2.0 $desc... "
710 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
711 cmp 50c.skip20.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
712 rm -f z50c.cue.$in_fmt
715 rm -f z50c.cue.$out_fmt
722 if [ $has_ogg = "yes" ] ; then
728 ############################################################################
729 # test 'fixup' code that happens when a FLAC file with total_samples == 0
730 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
731 # decoder go back and fix up the chunk headers
732 ############################################################################
734 echo -n "WAVE fixup test... "
736 echo -n "prepare... "
737 convert_to_wav noise || die "ERROR creating reference WAVE"
740 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
741 # binary-mode stdin problem, so we use an undocumented option to metaflac to
742 # set the total sample count to 0
743 if [ $is_win = yes ] ; then
744 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
745 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
747 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
751 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
753 echo -n "compare... "
754 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
757 rm -f noise.wav fixup.wav fixup.flac
759 echo -n "AIFF fixup test... "
761 echo -n "prepare... "
762 convert_to_aiff noise || die "ERROR creating reference AIFF"
765 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
766 # binary-mode stdin problem, so we use an undocumented option to metaflac to
767 # set the total sample count to 0
768 if [ $is_win = yes ] ; then
769 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
770 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
772 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
776 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
778 echo -n "compare... "
779 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
782 rm -f noise.aiff fixup.aiff fixup.flac
785 ############################################################################
787 ############################################################################
789 echo "Generating multiple input files from noise..."
790 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"
791 run_flac --decode --force --silent noise.flac || die "ERROR generating WAVE file"
793 mv noise.wav file0.wav
794 cp file0.wav file1.wav
795 cp file1.wav file2.wav
803 if [ $streamtype = ogg ] ; then
805 encode_options="$encode_options --ogg"
810 if [ $sector_align = sector_align ] ; then
811 encode_options="$encode_options --sector-align"
814 run_flac --force $encode_options file0.wav file1.wav file2.wav || die "ERROR"
816 mv file$n.$suffix file${n}x.$suffix
818 run_flac --force --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
819 if [ $sector_align != sector_align ] ; then
821 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
825 rm -f file${n}x.$suffix file${n}x.wav
829 echo "Testing multiple files without verify..."
830 test_multifile flac no_sector_align ""
832 echo "Testing multiple files with verify..."
833 test_multifile flac no_sector_align "--verify"
835 echo "Testing multiple files with --sector-align, without verify..."
836 test_multifile flac sector_align ""
838 echo "Testing multiple files with --sector-align, with verify..."
839 test_multifile flac sector_align "--verify"
841 if [ $has_ogg = "yes" ] ; then
842 echo "Testing multiple files with --ogg, without verify..."
843 test_multifile ogg no_sector_align ""
845 echo "Testing multiple files with --ogg, with verify..."
846 test_multifile ogg no_sector_align "--verify"
848 echo "Testing multiple files with --ogg and --sector-align, without verify..."
849 test_multifile ogg sector_align ""
851 echo "Testing multiple files with --ogg and --sector-align, with verify..."
852 test_multifile sector_align ogg "--verify"
854 echo "Testing multiple files with --ogg and --serial-number, with verify..."
855 test_multifile ogg no_sector_align "--serial-number=321 --verify"