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/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 -s -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 -s -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 -s -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 -s -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 ############################################################################
514 ############################################################################
517 # create the cue sheet
520 cat > $cuesheet << EOF
521 CATALOG 1234567890123
538 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
540 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
542 if [ $in_fmt = raw ] ; then
550 if [ $out_fmt = ogg ] ; then
554 desc="($in_fmt<->$out_fmt)"
557 # for this we need just need just one FLAC file; --cue only works while decoding
559 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
561 # To make it easy to translate from cue point to sample numbers, the
562 # file has a sample rate of 10 Hz and a cuesheet like so:
564 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
565 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
566 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
567 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
568 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
570 echo -n "testing --cue=- $desc... "
571 run_flac $dopt -o z50c.cue.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
572 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
573 rm -f z50c.cue.$in_fmt
576 echo -n "testing --cue=1.0 $desc... "
577 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
578 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
579 rm -f z50c.cue.$in_fmt
582 echo -n "testing --cue=1.0- $desc... "
583 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
584 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
585 rm -f z50c.cue.$in_fmt
588 echo -n "testing --cue=1.1 $desc... "
589 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
590 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
591 rm -f z50c.cue.$in_fmt
594 echo -n "testing --cue=1.1- $desc... "
595 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
596 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
597 rm -f z50c.cue.$in_fmt
600 echo -n "testing --cue=1.2 $desc... "
601 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
602 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
603 rm -f z50c.cue.$in_fmt
606 echo -n "testing --cue=1.2- $desc... "
607 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
608 cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
609 rm -f z50c.cue.$in_fmt
612 echo -n "testing --cue=1.4 $desc... "
613 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
614 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
615 rm -f z50c.cue.$in_fmt
618 echo -n "testing --cue=1.4- $desc... "
619 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
620 cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
621 rm -f z50c.cue.$in_fmt
624 echo -n "testing --cue=-5.0 $desc... "
625 run_flac $dopt -o z50c.cue.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
626 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
627 rm -f z50c.cue.$in_fmt
630 echo -n "testing --cue=-4.1 $desc... "
631 run_flac $dopt -o z50c.cue.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
632 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
633 rm -f z50c.cue.$in_fmt
636 echo -n "testing --cue=-3.1 $desc... "
637 run_flac $dopt -o z50c.cue.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
638 cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
639 rm -f z50c.cue.$in_fmt
642 echo -n "testing --cue=-1.4 $desc... "
643 run_flac $dopt -o z50c.cue.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
644 cmp 50c.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
645 rm -f z50c.cue.$in_fmt
648 echo -n "testing --cue=1.0-5.0 $desc... "
649 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
650 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
651 rm -f z50c.cue.$in_fmt
654 echo -n "testing --cue=1.1-5.0 $desc... "
655 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
656 cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
657 rm -f z50c.cue.$in_fmt
660 echo -n "testing --cue=1.2-4.1 $desc... "
661 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
662 cmp 50c.skip10.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
663 rm -f z50c.cue.$in_fmt
666 echo -n "testing --cue=1.4-2.0 $desc... "
667 run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
668 cmp 50c.skip20.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
669 rm -f z50c.cue.$in_fmt
672 rm -f z50c.cue.$out_fmt
679 if [ $has_ogg = "yes" ] ; then
685 ############################################################################
686 # test 'fixup' code that happens when a FLAC file with total_samples == 0
687 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
688 # decoder go back and fix up the chunk headers
689 ############################################################################
691 echo -n "WAVE fixup test... "
692 echo -n "prepare... "
693 convert_to_wav noise || die "ERROR creating reference WAVE"
695 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
697 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
698 echo -n "compare... "
699 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
701 rm -f noise.wav fixup.wav fixup.flac
703 echo -n "AIFF fixup test... "
704 echo -n "prepare... "
705 convert_to_aiff noise || die "ERROR creating reference AIFF"
707 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
709 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
710 echo -n "compare... "
711 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
713 rm -f noise.aiff fixup.aiff fixup.flac
716 ############################################################################
718 ############################################################################
720 echo "Generating multiple input files from noise..."
721 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"
722 run_flac --decode --force --silent noise.flac || die "ERROR generating WAVE file"
724 mv noise.wav file0.wav
725 cp file0.wav file1.wav
726 cp file1.wav file2.wav
734 if [ $streamtype = ogg ] ; then
736 encode_options="$encode_options --ogg"
741 if [ $sector_align = sector_align ] ; then
742 encode_options="$encode_options --sector-align"
745 run_flac --force $encode_options file0.wav file1.wav file2.wav || die "ERROR"
747 mv file$n.$suffix file${n}x.$suffix
749 run_flac --force --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
750 if [ $sector_align != sector_align ] ; then
752 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
756 rm -f file${n}x.$suffix file${n}x.wav
760 echo "Testing multiple files without verify..."
761 test_multifile flac no_sector_align ""
763 echo "Testing multiple files with verify..."
764 test_multifile flac no_sector_align "--verify"
766 echo "Testing multiple files with --sector-align, without verify..."
767 test_multifile flac sector_align ""
769 echo "Testing multiple files with --sector-align, with verify..."
770 test_multifile flac sector_align "--verify"
772 if [ $has_ogg = "yes" ] ; then
773 echo "Testing multiple files with --ogg, without verify..."
774 test_multifile ogg no_sector_align ""
776 echo "Testing multiple files with --ogg, with verify..."
777 test_multifile ogg no_sector_align "--verify"
779 echo "Testing multiple files with --ogg and --sector-align, without verify..."
780 test_multifile ogg sector_align ""
782 echo "Testing multiple files with --ogg and --sector-align, with verify..."
783 test_multifile sector_align ogg "--verify"
785 echo "Testing multiple files with --ogg and --serial-number, with verify..."
786 test_multifile ogg no_sector_align "--serial-number=321 --verify"