3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001,2002,2003,2004,2005,2006 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 if [ x = x"$1" ] ; then
32 # change to 'false' to show flac output (useful for debugging)
35 TOTALLY_SILENT='--totally-silent'
41 LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
42 LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
43 LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
44 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
45 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
46 LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
47 LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
48 export LD_LIBRARY_PATH
49 PATH=`pwd`/../src/flac:$PATH
50 PATH=`pwd`/../src/metaflac:$PATH
51 PATH=`pwd`/../src/test_streams:$PATH
52 PATH=`pwd`/../obj/$BUILD/bin:$PATH
54 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
58 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
59 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
67 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
68 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_flac.valgrind.log
76 #n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || die "ERROR: comparing FLAC files $1 and $2 by MD5 sum" ) | uniq | wc -l`
77 n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
78 [ "$n" != "" ] && [ $n = 1 ]
81 if [ `env | grep -ic '^comspec='` != 0 ] ; then
87 echo "Checking for --ogg support in flac..."
88 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
90 echo "flac --ogg works"
93 echo "flac --ogg doesn't work"
96 echo "Generating streams..."
97 if [ ! -f wacky1.wav ] ; then
98 test_streams || die "ERROR during test_streams"
101 ############################################################################
102 # test that flac doesn't automatically overwrite files unless -f is used
103 ############################################################################
105 echo "Try encoding to a file that exists; should fail"
106 cp wacky1.wav exist.wav
108 if run_flac $TOTALLY_SILENT -0 exist.wav ; then
109 die "ERROR: it should have failed but didn't"
111 echo "OK, it failed as it should"
114 echo "Try encoding with -f to a file that exists; should succeed"
115 if run_flac $TOTALLY_SILENT -0 --force exist.wav ; then
116 echo "OK, it succeeded as it should"
118 die "ERROR: it should have succeeded but didn't"
121 echo "Try decoding to a file that exists; should fail"
122 if run_flac $TOTALLY_SILENT -d exist.flac ; then
123 die "ERROR: it should have failed but didn't"
125 echo "OK, it failed as it should"
128 echo "Try decoding with -f to a file that exists; should succeed"
129 if run_flac $TOTALLY_SILENT -d -f exist.flac ; then
130 echo "OK, it succeeded as it should"
132 die "ERROR: it should have succeeded but didn't"
135 rm -f exist.wav exist.flac
137 ############################################################################
138 # basic 'round-trip' tests of various kinds of streams
139 ############################################################################
144 channels=`echo $f | awk -F- '{print $2}'`
145 bps=`echo $f | awk -F- '{print $3}'`
146 echo -n "round-trip test ($f) encode... "
147 run_flac $SILENT --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels --lax -o rt.flac $f || die "ERROR"
149 run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
150 echo -n "compare... "
151 cmp $f rt.raw || die "ERROR: file mismatch"
159 echo -n "round-trip test ($f) encode... "
160 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
162 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt.flac || die "ERROR"
163 echo -n "compare... "
164 cmp $f rt.wav || die "ERROR: file mismatch"
172 echo -n "round-trip test ($f) encode... "
173 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
175 run_flac $SILENT --force --decode --channel-map=none -o rt.aiff rt.flac || die "ERROR"
176 echo -n "compare... "
177 cmp $f rt.aiff || die "ERROR: file mismatch"
179 rm -f rt.flac rt.aiff
182 # assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
186 echo -n "round-trip test ($f->flac->flac->wav) encode... "
187 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
188 echo -n "re-encode... "
189 run_flac $SILENT --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
191 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.flac || die "ERROR"
192 echo -n "compare... "
193 cmp $f rt.wav || die "ERROR: file mismatch"
195 rm -f rt.wav rt.flac rt2.flac
198 for f in rt-*.raw ; do
201 for f in rt-*.wav ; do
204 for f in rt-*.aiff ; do
207 for f in rt-*.wav ; do
211 ############################################################################
212 # test --skip and --until
213 ############################################################################
216 # first make some chopped-up raw files
218 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
219 dddie="die ERROR: creating files with dd"
220 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
221 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
222 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
223 dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
224 dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
225 dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
226 dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
227 dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
228 dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
229 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
230 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
231 dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
232 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
233 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
234 dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
235 dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
237 wav_eopt="$SILENT --force --verify --lax"
238 wav_dopt="$SILENT --force --decode"
240 raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
241 raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
244 # convert them to WAVE and AIFF files
248 run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
249 run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
251 convert_to_wav 50c "$raw_eopt" "$wav_dopt"
252 convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
253 convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
254 convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
255 convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
256 convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
257 convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
258 convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
259 convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
260 convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
261 convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
262 convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
263 convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
264 convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
265 convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
266 convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
270 run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
271 run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
273 convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
274 convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
275 convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
276 convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
277 convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
278 convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
279 convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
280 convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
281 convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
282 convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
283 convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
284 convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
285 convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
286 convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
287 convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
288 convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
295 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
297 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
299 if [ $in_fmt = raw ] ; then
307 if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
313 if [ $out_fmt = ogg ] ; then
318 # test --skip when encoding
321 desc="($in_fmt<->$out_fmt)"
323 echo -n "testing --skip=# (encode) $desc... "
324 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
325 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
326 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
327 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
330 echo -n "testing --skip=mm:ss (encode) $desc... "
331 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
332 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
333 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
334 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
337 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
338 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
339 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0:01.1001.$in_fmt z50c.skip0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
340 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
341 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
345 # test --skip when decoding
348 if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
350 echo -n "testing --skip=# (decode) $desc... "
351 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
352 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
353 rm -f z50c.skip10.$in_fmt
356 echo -n "testing --skip=mm:ss (decode) $desc... "
357 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
358 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
359 rm -f z50c.skip0:01.$in_fmt
362 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
363 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
364 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
365 rm -f z50c.skip0:01.1001.$in_fmt
371 # test --until when encoding
374 echo -n "testing --until=# (encode) $desc... "
375 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
376 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
377 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
378 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
381 echo -n "testing --until=mm:ss (encode) $desc... "
382 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
383 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
384 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
385 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
388 echo -n "testing --until=mm:ss.sss (encode) $desc... "
389 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
390 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0:03.9001.$in_fmt z50c.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
391 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
392 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
395 echo -n "testing --until=-# (encode) $desc... "
396 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
397 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
398 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
399 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
402 echo -n "testing --until=-mm:ss (encode) $desc... "
403 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
404 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0:01.$in_fmt z50c.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
405 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
406 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
409 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
410 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
411 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0:01.1001.$in_fmt z50c.until-0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
412 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
413 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
417 # test --until when decoding
420 if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
422 echo -n "testing --until=# (decode) $desc... "
423 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
424 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
425 rm -f z50c.until40.$in_fmt
428 echo -n "testing --until=mm:ss (decode) $desc... "
429 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
430 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
431 rm -f z50c.until0:04.$in_fmt
434 echo -n "testing --until=mm:ss.sss (decode) $desc... "
435 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
436 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
437 rm -f z50c.until0:03.9001.$in_fmt
440 echo -n "testing --until=-# (decode) $desc... "
441 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
442 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
443 rm -f z50c.until-10.$in_fmt
446 echo -n "testing --until=-mm:ss (decode) $desc... "
447 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
448 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
449 rm -f z50c.until-0:01.$in_fmt
452 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
453 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
454 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
455 rm -f z50c.until-0:01.1001.$in_fmt
461 # test --skip and --until when encoding
464 echo -n "testing --skip=10 --until=# (encode) $desc... "
465 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
466 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
467 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
468 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
471 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
472 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
473 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0:04.$in_fmt z50c.skip10.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
474 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
475 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
478 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
479 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"
480 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0:03.9001.$in_fmt z50c.skip10.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
481 $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"
482 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
485 echo -n "testing --skip=10 --until=+# (encode) $desc... "
486 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
487 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
488 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
489 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
492 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
493 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"
494 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0:03.$in_fmt z50c.skip10.until+0:03.$out_fmt || die "ERROR decoding FLAC file $desc"
495 $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"
496 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
499 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
500 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"
501 [ $in_fmt = $out_fmt ] || 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"
502 $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"
503 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
506 echo -n "testing --skip=10 --until=-# (encode) $desc... "
507 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
508 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
509 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
510 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
513 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
514 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"
515 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0:01.$in_fmt z50c.skip10.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
516 $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"
517 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
520 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
521 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"
522 [ $in_fmt = $out_fmt ] || 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"
523 $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"
524 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
528 # test --skip and --until when decoding
531 if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
534 echo -n "testing --skip=10 --until=# (decode) $desc... "
535 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
536 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
537 rm -f z50c.skip10.until40.$in_fmt
540 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
541 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
542 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
543 rm -f z50c.skip10.until0:04.$in_fmt
546 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
547 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"
548 $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"
549 rm -f z50c.skip10.until0:03.9001.$in_fmt
552 echo -n "testing --skip=10 --until=-# (decode) $desc... "
553 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
554 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
555 rm -f z50c.skip10.until-10.$in_fmt
558 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
559 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"
560 $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"
561 rm -f z50c.skip10.until-0:01.$in_fmt
564 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
565 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"
566 $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"
567 rm -f z50c.skip10.until-0:01.1001.$in_fmt
573 test_skip_until raw flac
574 test_skip_until wav flac
575 test_skip_until aiff flac
576 test_skip_until flac flac
578 if [ $has_ogg = "yes" ] ; then
579 test_skip_until raw ogg
580 test_skip_until wav ogg
581 test_skip_until aiff ogg
582 #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
583 #@@@test_skip_until flac ogg
586 echo "testing seek extremes:"
588 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"
590 if [ $is_win = no ] ; then
591 total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
592 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
594 # some flavors of cygwin don't seem to treat the \x0d as a word
595 # separator, so we hard code it. we'll just have to fix it later
596 # if we change the way noise.flac is made.
597 total_noise_cdda_samples=393216
600 echo -n "testing --skip=0... "
601 run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
604 for delta in 2 1 ; do
605 n=`expr $total_noise_cdda_samples - $delta`
606 echo -n "testing --skip=$n... "
607 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
614 ############################################################################
616 ############################################################################
618 #@@@ cat will not work on old cygwin, need to fix
619 if [ $is_win = no ] ; then
620 echo -n "testing --input-size=50 --skip=10... "
621 cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
622 run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
623 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
624 rm -f z50c.skip10.raw z50c.skip10.flac
629 ############################################################################
631 ############################################################################
634 # create the cue sheet
637 cat > $cuesheet << EOF
638 CATALOG 1234567890123
655 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
657 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
659 if [ $in_fmt = raw ] ; then
667 if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
673 if [ $out_fmt = ogg ] ; then
677 desc="($in_fmt<->$out_fmt)"
680 # for this we need just need just one FLAC file; --cue only works while decoding
682 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
684 # To make it easy to translate from cue point to sample numbers, the
685 # file has a sample rate of 10 Hz and a cuesheet like so:
687 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
688 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
689 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
690 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
691 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
693 echo -n "testing --cue=- $desc... "
694 run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
695 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
696 rm -f z50c.cued.$in_fmt
699 echo -n "testing --cue=1.0 $desc... "
700 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
701 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
702 rm -f z50c.cued.$in_fmt
705 echo -n "testing --cue=1.0- $desc... "
706 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
707 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
708 rm -f z50c.cued.$in_fmt
711 echo -n "testing --cue=1.1 $desc... "
712 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
713 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
714 rm -f z50c.cued.$in_fmt
717 echo -n "testing --cue=1.1- $desc... "
718 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
719 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
720 rm -f z50c.cued.$in_fmt
723 echo -n "testing --cue=1.2 $desc... "
724 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
725 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
726 rm -f z50c.cued.$in_fmt
729 echo -n "testing --cue=1.2- $desc... "
730 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
731 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
732 rm -f z50c.cued.$in_fmt
735 echo -n "testing --cue=1.4 $desc... "
736 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
737 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
738 rm -f z50c.cued.$in_fmt
741 echo -n "testing --cue=1.4- $desc... "
742 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
743 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
744 rm -f z50c.cued.$in_fmt
747 echo -n "testing --cue=-5.0 $desc... "
748 run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
749 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
750 rm -f z50c.cued.$in_fmt
753 echo -n "testing --cue=-4.1 $desc... "
754 run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
755 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
756 rm -f z50c.cued.$in_fmt
759 echo -n "testing --cue=-3.1 $desc... "
760 run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
761 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
762 rm -f z50c.cued.$in_fmt
765 echo -n "testing --cue=-1.4 $desc... "
766 run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
767 $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
768 rm -f z50c.cued.$in_fmt
771 echo -n "testing --cue=1.0-5.0 $desc... "
772 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
773 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
774 rm -f z50c.cued.$in_fmt
777 echo -n "testing --cue=1.1-5.0 $desc... "
778 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
779 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
780 rm -f z50c.cued.$in_fmt
783 echo -n "testing --cue=1.2-4.1 $desc... "
784 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
785 $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
786 rm -f z50c.cued.$in_fmt
789 echo -n "testing --cue=1.4-2.0 $desc... "
790 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
791 $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
792 rm -f z50c.cued.$in_fmt
795 rm -f z50c.cue.$out_fmt
803 if [ $has_ogg = "yes" ] ; then
807 #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
808 #@@@test_cue flac ogg
811 ############################################################################
812 # test 'fixup' code that happens when a FLAC file with total_samples == 0
813 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
814 # decoder go back and fix up the chunk headers
815 ############################################################################
817 echo -n "WAVE fixup test... "
819 echo -n "prepare... "
820 convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
823 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
824 # binary-mode stdin problem, so we use an undocumented option to metaflac to
825 # set the total sample count to 0
826 if [ $is_win = yes ] ; then
827 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
828 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
830 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
834 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
836 echo -n "compare... "
837 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
840 rm -f noise.wav fixup.wav fixup.flac
842 echo -n "AIFF fixup test... "
844 echo -n "prepare... "
845 convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
848 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
849 # binary-mode stdin problem, so we use an undocumented option to metaflac to
850 # set the total sample count to 0
851 if [ $is_win = yes ] ; then
852 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
853 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
855 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
859 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
861 echo -n "compare... "
862 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
865 rm -f noise.aiff fixup.aiff fixup.flac
868 ############################################################################
870 ############################################################################
872 echo "Generating multiple input files from noise..."
873 multifile_format_decode="--endian=big --sign=signed"
874 multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2"
875 short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
876 run_flac --verify --force $SILENT --force-raw-format $multifile_format_encode --until=$short_noise_cdda_samples -o shortnoise.flac noise.raw || die "ERROR generating FLAC file"
877 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
878 run_flac --decode --force $SILENT shortnoise.flac || die "ERROR generating WAVE file"
879 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
880 cp shortnoise.flac file0.flac
881 cp shortnoise.flac file1.flac
882 cp shortnoise.flac file2.flac
883 rm -f shortnoise.flac
884 cp shortnoise.wav file0.wav
885 cp shortnoise.wav file1.wav
886 cp shortnoise.wav file2.wav
888 cp shortnoise.aiff file0.aiff
889 cp shortnoise.aiff file1.aiff
890 cp shortnoise.aiff file2.aiff
891 rm -f shortnoise.aiff
892 cp shortnoise.raw file0.raw
893 cp shortnoise.raw file1.raw
894 cp shortnoise.raw file2.raw
896 # create authoritative sector-aligned files for comparison
897 file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
898 file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
899 file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
900 file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
901 file1_samples=`expr $file1_samples - $file0_remainder`
902 file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
903 file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
904 file2_samples=`expr $file2_samples - $file1_remainder`
905 if [ $file2_remainder != '0' ] ; then
906 file2_samples=`expr $file2_samples + $file2_remainder`
907 file2_remainder=`expr 588 - $file2_remainder`
910 dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
911 dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
912 dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
913 cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
914 dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
915 dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
916 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
917 dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
918 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
921 convert_to_wav file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
922 convert_to_wav file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
923 convert_to_wav file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
925 convert_to_aiff file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
926 convert_to_aiff file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
927 convert_to_aiff file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
936 extra_encode_options=""
937 extra_decode_options=""
938 if [ $input_type = "raw" ] ; then
939 extra_encode_options="--force-raw-format $multifile_format_encode"
940 extra_decode_options="--force-raw-format $multifile_format_decode"
942 if [ $input_type = "aiff" ] ; then
943 extra_decode_options="--force-aiff-format"
947 if [ $streamtype = ogg ] ; then
949 encode_options="$encode_options --ogg"
954 if [ $sector_align = sector_align ] ; then
955 encode_options="$encode_options --sector-align"
958 if [ $input_type = flac ] ; then
965 cp file$n.$input_type file${n}x.$input_type
967 run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
968 run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
969 if [ $sector_align != sector_align ] ; then
971 $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
975 $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
979 rm -f file${n}x.$suffix file${n}x.$input_type
983 for input_type in raw wav aiff flac ; do
984 echo "Testing multiple $input_type files without verify..."
985 test_multifile $input_type flac no_sector_align ""
987 echo "Testing multiple $input_type files with verify..."
988 test_multifile $input_type flac no_sector_align "--verify"
990 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
991 echo "Testing multiple $input_type files with --sector-align, without verify..."
992 test_multifile $input_type flac sector_align ""
994 echo "Testing multiple $input_type files with --sector-align, with verify..."
995 test_multifile $input_type flac sector_align "--verify"
998 if [ $has_ogg = "yes" ] ; then
999 echo "Testing multiple $input_type files with --ogg, without verify..."
1000 test_multifile $input_type ogg no_sector_align ""
1002 echo "Testing multiple $input_type files with --ogg, with verify..."
1003 test_multifile $input_type ogg no_sector_align "--verify"
1005 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
1006 echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
1007 test_multifile $input_type ogg sector_align ""
1009 echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
1010 test_multifile $input_type ogg sector_align "--verify"
1013 echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
1014 test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
1019 ############################################################################
1020 # test the metadata-handling properties of flac-to-flac encoding
1021 ############################################################################
1023 echo "Testing the metadata-handling properties of flac-to-flac encoding..."
1025 testdir="flac-to-flac-metadata-test-files"
1028 # minor danger, changing vendor strings will change the length of the
1029 # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
1030 # we lose info about PADDING size that we need
1031 grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
1038 expect="$case-expect.meta"
1040 run_flac $SILENT -f -o out.flac $args $file || die "ERROR encoding FLAC file"
1041 run_metaflac --list out.flac | filter > out.meta || die "ERROR listing metadata of output FLAC file"
1042 diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
1046 #filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
1047 cd $testdir || die "ERROR changing to directory $testdir"
1049 # case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
1050 flac2flac input-SCVAUP.flac case00a ""
1051 # case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
1052 flac2flac input-SCVPAP.flac case01a ""
1053 # case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
1054 flac2flac input-SCVPAP.flac case01b "--no-padding"
1055 # case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
1056 flac2flac input-SCVPAP.flac case01c "-P 1234"
1057 # case 01d: on file with no PADDING blocks, use -P setting
1058 flac2flac input-SCVA.flac case01d "-P 1234"
1059 # case 01e: on file with no PADDING blocks and no -P given, use default padding
1060 flac2flac input-SCVA.flac case01e ""
1061 # case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
1062 flac2flac input-SCPAP.flac case02a ""
1063 # case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
1064 flac2flac input-SCPAP.flac case02b "--tag=artist=0"
1065 # case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
1066 flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
1067 # case 03a: on file with no CUESHEET block and --cuesheet specified, add it
1068 flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
1069 # case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
1070 flac2flac input-SCVAUP.flac case03b "$TOTALLY_SILENT --cuesheet=input0.cue"
1071 # case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
1072 flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
1073 # case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
1074 flac2flac input-VA.flac case04a "--no-padding --no-seektable"
1075 # case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
1076 flac2flac input-VA.flac case04b "--no-padding -S 5x"
1077 # case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
1078 flac2flac input-VA.flac case04c "--no-padding"
1079 # case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
1080 flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
1081 # case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
1082 flac2flac input-SCVA.flac case04e "$TOTALLY_SILENT --no-padding -S 5x"
1083 # case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
1084 #(already covered by case03c)
1086 rm -f out.flac out.meta