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 # assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
202 echo -n "round-trip test ($f->oggflac->oggflac->wav) encode... "
203 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.ogg --ogg $f || die "ERROR"
204 echo -n "re-encode... "
205 run_flac $SILENT --force --verify --lax -o rt2.ogg --ogg rt.ogg || die "ERROR"
207 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.ogg || die "ERROR"
208 echo -n "compare... "
209 cmp $f rt.wav || die "ERROR: file mismatch"
211 rm -f rt.wav rt.ogg rt2.ogg
214 for f in rt-*.raw ; do
217 for f in rt-*.wav ; do
220 for f in rt-*.aiff ; do
223 for f in rt-*.wav ; do
226 if [ $has_ogg = yes ] ; then
227 for f in rt-*.wav ; do
232 ############################################################################
233 # test --skip and --until
234 ############################################################################
237 # first make some chopped-up raw files
239 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
240 dddie="die ERROR: creating files with dd"
241 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
242 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
243 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
244 dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
245 dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
246 dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
247 dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
248 dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
249 dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
250 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
251 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
252 dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
253 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
254 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
255 dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
256 dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
258 wav_eopt="$SILENT --force --verify --lax"
259 wav_dopt="$SILENT --force --decode"
261 raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
262 raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
265 # convert them to WAVE/AIFF/Ogg FLAC files
269 run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
270 run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
272 convert_to_wav 50c "$raw_eopt" "$wav_dopt"
273 convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
274 convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
275 convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
276 convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
277 convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
278 convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
279 convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
280 convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
281 convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
282 convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
283 convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
284 convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
285 convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
286 convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
287 convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
291 run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
292 run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
294 convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
295 convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
296 convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
297 convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
298 convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
299 convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
300 convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
301 convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
302 convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
303 convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
304 convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
305 convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
306 convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
307 convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
308 convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
309 convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
313 run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
315 if [ $has_ogg = yes ] ; then
317 convert_to_ogg 50c.skip10
318 convert_to_ogg 50c.skip11
319 convert_to_ogg 50c.skip20
320 convert_to_ogg 50c.skip30
321 convert_to_ogg 50c.skip40
322 convert_to_ogg 50c.until10
323 convert_to_ogg 50c.until20
324 convert_to_ogg 50c.until30
325 convert_to_ogg 50c.until39
326 convert_to_ogg 50c.until40
327 convert_to_ogg 50c.skip10.until30
328 convert_to_ogg 50c.skip10.until39
329 convert_to_ogg 50c.skip10.until40
330 convert_to_ogg 50c.skip20.until30
331 convert_to_ogg 50c.skip20.until40
339 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
341 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
343 if [ $in_fmt = raw ] ; then
351 if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
357 if [ $out_fmt = ogg ] ; then
362 # test --skip when encoding
365 desc="($in_fmt<->$out_fmt)"
367 echo -n "testing --skip=# (encode) $desc... "
368 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
369 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
370 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
371 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
374 echo -n "testing --skip=mm:ss (encode) $desc... "
375 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
376 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
377 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
378 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
381 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
382 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
383 [ $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"
384 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
385 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
389 # test --skip when decoding
392 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"
394 echo -n "testing --skip=# (decode) $desc... "
395 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
396 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
397 rm -f z50c.skip10.$in_fmt
400 echo -n "testing --skip=mm:ss (decode) $desc... "
401 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
402 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
403 rm -f z50c.skip0:01.$in_fmt
406 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
407 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
408 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
409 rm -f z50c.skip0:01.1001.$in_fmt
415 # test --until when encoding
418 echo -n "testing --until=# (encode) $desc... "
419 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
420 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
421 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
422 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
425 echo -n "testing --until=mm:ss (encode) $desc... "
426 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
427 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
428 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
429 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
432 echo -n "testing --until=mm:ss.sss (encode) $desc... "
433 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
434 [ $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"
435 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
436 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
439 echo -n "testing --until=-# (encode) $desc... "
440 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
441 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$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 (encode) $desc"
443 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
446 echo -n "testing --until=-mm:ss (encode) $desc... "
447 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
448 [ $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"
449 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
450 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
453 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
454 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
455 [ $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"
456 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
457 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
461 # test --until when decoding
464 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"
466 echo -n "testing --until=# (decode) $desc... "
467 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
468 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
469 rm -f z50c.until40.$in_fmt
472 echo -n "testing --until=mm:ss (decode) $desc... "
473 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
474 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
475 rm -f z50c.until0:04.$in_fmt
478 echo -n "testing --until=mm:ss.sss (decode) $desc... "
479 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
480 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
481 rm -f z50c.until0:03.9001.$in_fmt
484 echo -n "testing --until=-# (decode) $desc... "
485 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
486 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
487 rm -f z50c.until-10.$in_fmt
490 echo -n "testing --until=-mm:ss (decode) $desc... "
491 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
492 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
493 rm -f z50c.until-0:01.$in_fmt
496 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
497 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
498 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
499 rm -f z50c.until-0:01.1001.$in_fmt
505 # test --skip and --until when encoding
508 echo -n "testing --skip=10 --until=# (encode) $desc... "
509 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
510 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
511 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
512 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
515 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
516 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
517 [ $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"
518 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
519 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
522 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
523 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"
524 [ $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"
525 $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"
526 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
529 echo -n "testing --skip=10 --until=+# (encode) $desc... "
530 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
531 [ $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"
532 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
533 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
536 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
537 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"
538 [ $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"
539 $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"
540 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
543 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
544 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"
545 [ $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"
546 $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"
547 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
550 echo -n "testing --skip=10 --until=-# (encode) $desc... "
551 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
552 [ $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"
553 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
554 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
557 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
558 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"
559 [ $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"
560 $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"
561 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
564 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
565 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"
566 [ $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"
567 $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"
568 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
572 # test --skip and --until when decoding
575 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"
578 echo -n "testing --skip=10 --until=# (decode) $desc... "
579 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
580 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
581 rm -f z50c.skip10.until40.$in_fmt
584 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
585 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
586 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
587 rm -f z50c.skip10.until0:04.$in_fmt
590 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
591 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"
592 $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"
593 rm -f z50c.skip10.until0:03.9001.$in_fmt
596 echo -n "testing --skip=10 --until=-# (decode) $desc... "
597 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
598 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
599 rm -f z50c.skip10.until-10.$in_fmt
602 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
603 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"
604 $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"
605 rm -f z50c.skip10.until-0:01.$in_fmt
608 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
609 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"
610 $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"
611 rm -f z50c.skip10.until-0:01.1001.$in_fmt
617 test_skip_until raw flac
618 test_skip_until wav flac
619 test_skip_until aiff flac
620 test_skip_until flac flac
621 #@@@if [ $has_ogg = yes ] ; then
622 #@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
623 #@@@ test_skip_until ogg flac
626 if [ $has_ogg = yes ] ; then
627 test_skip_until raw ogg
628 test_skip_until wav ogg
629 test_skip_until aiff ogg
630 #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
631 #@@@test_skip_until flac ogg
632 #@@@test_skip_until ogg ogg
635 echo "testing seek extremes:"
637 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"
639 if [ $is_win = no ] ; then
640 total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
641 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
643 # some flavors of cygwin don't seem to treat the \x0d as a word
644 # separator, so we hard code it. we'll just have to fix it later
645 # if we change the way noise.flac is made.
646 total_noise_cdda_samples=393216
649 echo -n "testing --skip=0... "
650 run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
653 for delta in 2 1 ; do
654 n=`expr $total_noise_cdda_samples - $delta`
655 echo -n "testing --skip=$n... "
656 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
663 ############################################################################
665 ############################################################################
667 #@@@ cat will not work on old cygwin, need to fix
668 if [ $is_win = no ] ; then
669 echo -n "testing --input-size=50 --skip=10... "
670 cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
671 run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
672 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
673 rm -f z50c.skip10.raw z50c.skip10.flac
678 ############################################################################
680 ############################################################################
683 # create the cue sheet
686 cat > $cuesheet << EOF
687 CATALOG 1234567890123
704 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
706 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
708 if [ $in_fmt = raw ] ; then
716 if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
722 if [ $out_fmt = ogg ] ; then
726 desc="($in_fmt<->$out_fmt)"
729 # for this we need just need just one FLAC file; --cue only works while decoding
731 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
733 # To make it easy to translate from cue point to sample numbers, the
734 # file has a sample rate of 10 Hz and a cuesheet like so:
736 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
737 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
738 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
739 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
740 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
742 echo -n "testing --cue=- $desc... "
743 run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
744 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
745 rm -f z50c.cued.$in_fmt
748 echo -n "testing --cue=1.0 $desc... "
749 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
750 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
751 rm -f z50c.cued.$in_fmt
754 echo -n "testing --cue=1.0- $desc... "
755 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
756 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
757 rm -f z50c.cued.$in_fmt
760 echo -n "testing --cue=1.1 $desc... "
761 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
762 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
763 rm -f z50c.cued.$in_fmt
766 echo -n "testing --cue=1.1- $desc... "
767 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
768 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
769 rm -f z50c.cued.$in_fmt
772 echo -n "testing --cue=1.2 $desc... "
773 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
774 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
775 rm -f z50c.cued.$in_fmt
778 echo -n "testing --cue=1.2- $desc... "
779 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
780 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
781 rm -f z50c.cued.$in_fmt
784 echo -n "testing --cue=1.4 $desc... "
785 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
786 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
787 rm -f z50c.cued.$in_fmt
790 echo -n "testing --cue=1.4- $desc... "
791 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
792 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
793 rm -f z50c.cued.$in_fmt
796 echo -n "testing --cue=-5.0 $desc... "
797 run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
798 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
799 rm -f z50c.cued.$in_fmt
802 echo -n "testing --cue=-4.1 $desc... "
803 run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
804 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
805 rm -f z50c.cued.$in_fmt
808 echo -n "testing --cue=-3.1 $desc... "
809 run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
810 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
811 rm -f z50c.cued.$in_fmt
814 echo -n "testing --cue=-1.4 $desc... "
815 run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
816 $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
817 rm -f z50c.cued.$in_fmt
820 echo -n "testing --cue=1.0-5.0 $desc... "
821 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
822 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
823 rm -f z50c.cued.$in_fmt
826 echo -n "testing --cue=1.1-5.0 $desc... "
827 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
828 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
829 rm -f z50c.cued.$in_fmt
832 echo -n "testing --cue=1.2-4.1 $desc... "
833 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
834 $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
835 rm -f z50c.cued.$in_fmt
838 echo -n "testing --cue=1.4-2.0 $desc... "
839 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
840 $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
841 rm -f z50c.cued.$in_fmt
844 rm -f z50c.cue.$out_fmt
851 #@@@if [ $has_ogg = yes ] ; then
852 #@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
853 #@@@ test_cue ogg flac
856 if [ $has_ogg = yes ] ; then
860 #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
861 #@@@test_cue flac ogg
865 ############################################################################
866 # test 'fixup' code that happens when a FLAC file with total_samples == 0
867 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
868 # decoder go back and fix up the chunk headers
869 ############################################################################
871 echo -n "WAVE fixup test... "
873 echo -n "prepare... "
874 convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
877 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
878 # binary-mode stdin problem, so we use an undocumented option to metaflac to
879 # set the total sample count to 0
880 if [ $is_win = yes ] ; then
881 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
882 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
884 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
888 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
890 echo -n "compare... "
891 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
894 rm -f noise.wav fixup.wav fixup.flac
896 echo -n "AIFF fixup test... "
898 echo -n "prepare... "
899 convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
902 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
903 # binary-mode stdin problem, so we use an undocumented option to metaflac to
904 # set the total sample count to 0
905 if [ $is_win = yes ] ; then
906 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
907 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
909 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
913 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
915 echo -n "compare... "
916 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
919 rm -f noise.aiff fixup.aiff fixup.flac
922 ############################################################################
924 ############################################################################
926 echo "Generating multiple input files from noise..."
927 multifile_format_decode="--endian=big --sign=signed"
928 multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2"
929 short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
930 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"
931 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
932 run_flac --decode --force $SILENT shortnoise.flac || die "ERROR generating WAVE file"
933 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
934 cp shortnoise.flac file0.flac
935 cp shortnoise.flac file1.flac
936 cp shortnoise.flac file2.flac
937 rm -f shortnoise.flac
938 cp shortnoise.wav file0.wav
939 cp shortnoise.wav file1.wav
940 cp shortnoise.wav file2.wav
942 cp shortnoise.aiff file0.aiff
943 cp shortnoise.aiff file1.aiff
944 cp shortnoise.aiff file2.aiff
945 rm -f shortnoise.aiff
946 cp shortnoise.raw file0.raw
947 cp shortnoise.raw file1.raw
948 cp shortnoise.raw file2.raw
950 # create authoritative sector-aligned files for comparison
951 file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
952 file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
953 file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
954 file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
955 file1_samples=`expr $file1_samples - $file0_remainder`
956 file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
957 file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
958 file2_samples=`expr $file2_samples - $file1_remainder`
959 if [ $file2_remainder != '0' ] ; then
960 file2_samples=`expr $file2_samples + $file2_remainder`
961 file2_remainder=`expr 588 - $file2_remainder`
964 dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
965 dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
966 dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
967 cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
968 dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
969 dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
970 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
971 dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
972 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
975 convert_to_wav file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
976 convert_to_wav file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
977 convert_to_wav file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
979 convert_to_aiff file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
980 convert_to_aiff file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
981 convert_to_aiff file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
990 extra_encode_options=""
991 extra_decode_options=""
992 if [ $input_type = "raw" ] ; then
993 extra_encode_options="--force-raw-format $multifile_format_encode"
994 extra_decode_options="--force-raw-format $multifile_format_decode"
996 if [ $input_type = "aiff" ] ; then
997 extra_decode_options="--force-aiff-format"
1001 if [ $streamtype = ogg ] ; then
1003 encode_options="$encode_options --ogg"
1008 if [ $sector_align = sector_align ] ; then
1009 encode_options="$encode_options --sector-align"
1012 if [ $input_type = flac ] || [ $input_type = ogg ] ; then
1019 cp file$n.$input_type file${n}x.$input_type
1021 run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
1022 run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
1023 if [ $sector_align != sector_align ] ; then
1025 $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
1029 $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
1033 rm -f file${n}x.$suffix file${n}x.$input_type
1037 input_types="raw wav aiff flac"
1038 #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
1039 #@@@if [ $has_ogg = yes ] ; then
1040 #@@@ input_types="$input_types ogg"
1042 for input_type in $input_types ; do
1043 echo "Testing multiple $input_type files without verify..."
1044 test_multifile $input_type flac no_sector_align ""
1046 echo "Testing multiple $input_type files with verify..."
1047 test_multifile $input_type flac no_sector_align "--verify"
1049 if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
1050 echo "Testing multiple $input_type files with --sector-align, without verify..."
1051 test_multifile $input_type flac sector_align ""
1053 echo "Testing multiple $input_type files with --sector-align, with verify..."
1054 test_multifile $input_type flac sector_align "--verify"
1057 if [ $has_ogg = yes ] ; then
1058 echo "Testing multiple $input_type files with --ogg, without verify..."
1059 test_multifile $input_type ogg no_sector_align ""
1061 echo "Testing multiple $input_type files with --ogg, with verify..."
1062 test_multifile $input_type ogg no_sector_align "--verify"
1064 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
1065 echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
1066 test_multifile $input_type ogg sector_align ""
1068 echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
1069 test_multifile $input_type ogg sector_align "--verify"
1072 echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
1073 test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
1078 ############################################################################
1079 # test the metadata-handling properties of flac-to-flac encoding
1080 ############################################################################
1082 echo "Testing the metadata-handling properties of flac-to-flac encoding..."
1084 testdir="flac-to-flac-metadata-test-files"
1087 # minor danger, changing vendor strings will change the length of the
1088 # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
1089 # we lose info about PADDING size that we need
1090 grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
1097 expect="$case-expect.meta"
1099 run_flac $SILENT -f -o out.flac $args $file || die "ERROR encoding FLAC file"
1100 run_metaflac --list out.flac | filter > out.meta || die "ERROR listing metadata of output FLAC file"
1101 diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
1105 #filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
1106 cd $testdir || die "ERROR changing to directory $testdir"
1108 # case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
1109 flac2flac input-SCVAUP.flac case00a ""
1110 # case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
1111 flac2flac input-SCVPAP.flac case01a ""
1112 # case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
1113 flac2flac input-SCVPAP.flac case01b "--no-padding"
1114 # case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
1115 flac2flac input-SCVPAP.flac case01c "-P 1234"
1116 # case 01d: on file with no PADDING blocks, use -P setting
1117 flac2flac input-SCVA.flac case01d "-P 1234"
1118 # case 01e: on file with no PADDING blocks and no -P given, use default padding
1119 flac2flac input-SCVA.flac case01e ""
1120 # case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
1121 flac2flac input-SCPAP.flac case02a ""
1122 # case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
1123 flac2flac input-SCPAP.flac case02b "--tag=artist=0"
1124 # case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
1125 flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
1126 # case 03a: on file with no CUESHEET block and --cuesheet specified, add it
1127 flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
1128 # case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
1129 flac2flac input-SCVAUP.flac case03b "$TOTALLY_SILENT --cuesheet=input0.cue"
1130 # case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
1131 flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
1132 # case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
1133 flac2flac input-VA.flac case04a "--no-padding --no-seektable"
1134 # case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
1135 flac2flac input-VA.flac case04b "--no-padding -S 5x"
1136 # case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
1137 flac2flac input-VA.flac case04c "--no-padding"
1138 # case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
1139 flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
1140 # case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
1141 flac2flac input-SCVA.flac case04e "$TOTALLY_SILENT --no-padding -S 5x"
1142 # case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
1143 #(already covered by case03c)
1145 rm -f out.flac out.meta
1147 #@@@ when metaflac handles ogg flac, duplicate flac2flac tests here