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/libOggFLAC/.libs:$LD_LIBRARY_PATH
43 LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
44 LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
45 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
46 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
47 LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
48 LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
49 export LD_LIBRARY_PATH
50 PATH=`pwd`/../src/flac:$PATH
51 PATH=`pwd`/../src/metaflac:$PATH
52 PATH=`pwd`/../src/test_streams:$PATH
53 PATH=`pwd`/../obj/$BUILD/bin:$PATH
55 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
59 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
60 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
68 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
69 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_flac.valgrind.log
77 #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`
78 n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
79 [ "$n" != "" ] && [ $n = 1 ]
82 if [ `env | grep -ic '^comspec='` != 0 ] ; then
88 echo "Checking for --ogg support in flac..."
89 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
91 echo "flac --ogg works"
94 echo "flac --ogg doesn't work"
97 echo "Generating streams..."
98 if [ ! -f wacky1.wav ] ; then
99 test_streams || die "ERROR during test_streams"
102 ############################################################################
103 # test that flac doesn't automatically overwrite files unless -f is used
104 ############################################################################
106 echo "Try encoding to a file that exists; should fail"
107 cp wacky1.wav exist.wav
109 if run_flac $TOTALLY_SILENT -0 exist.wav ; then
110 die "ERROR: it should have failed but didn't"
112 echo "OK, it failed as it should"
115 echo "Try encoding with -f to a file that exists; should succeed"
116 if run_flac $TOTALLY_SILENT -0 --force exist.wav ; then
117 echo "OK, it succeeded as it should"
119 die "ERROR: it should have succeeded but didn't"
122 echo "Try decoding to a file that exists; should fail"
123 if run_flac $TOTALLY_SILENT -d exist.flac ; then
124 die "ERROR: it should have failed but didn't"
126 echo "OK, it failed as it should"
129 echo "Try decoding with -f to a file that exists; should succeed"
130 if run_flac $TOTALLY_SILENT -d -f exist.flac ; then
131 echo "OK, it succeeded as it should"
133 die "ERROR: it should have succeeded but didn't"
136 rm -f exist.wav exist.flac
138 ############################################################################
139 # basic 'round-trip' tests of various kinds of streams
140 ############################################################################
145 channels=`echo $f | awk -F- '{print $2}'`
146 bps=`echo $f | awk -F- '{print $3}'`
147 echo -n "round-trip test ($f) encode... "
148 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"
150 run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
151 echo -n "compare... "
152 cmp $f rt.raw || die "ERROR: file mismatch"
160 echo -n "round-trip test ($f) encode... "
161 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
163 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt.flac || die "ERROR"
164 echo -n "compare... "
165 cmp $f rt.wav || die "ERROR: file mismatch"
173 echo -n "round-trip test ($f) encode... "
174 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
176 run_flac $SILENT --force --decode --channel-map=none -o rt.aiff rt.flac || die "ERROR"
177 echo -n "compare... "
178 cmp $f rt.aiff || die "ERROR: file mismatch"
180 rm -f rt.flac rt.aiff
183 # assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
187 echo -n "round-trip test ($f->flac->flac->wav) encode... "
188 run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
189 echo -n "re-encode... "
190 run_flac $SILENT --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
192 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.flac || die "ERROR"
193 echo -n "compare... "
194 cmp $f rt.wav || die "ERROR: file mismatch"
196 rm -f rt.wav rt.flac rt2.flac
199 for f in rt-*.raw ; do
202 for f in rt-*.wav ; do
205 for f in rt-*.aiff ; do
208 for f in rt-*.wav ; do
212 ############################################################################
213 # test --skip and --until
214 ############################################################################
217 # first make some chopped-up raw files
219 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
220 dddie="die ERROR: creating files with dd"
221 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
222 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
223 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
224 dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
225 dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
226 dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
227 dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
228 dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
229 dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
230 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
231 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
232 dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
233 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
234 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
235 dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
236 dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
238 wav_eopt="$SILENT --force --verify --lax"
239 wav_dopt="$SILENT --force --decode"
241 raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
242 raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
245 # convert them to WAVE and AIFF files
249 run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
250 run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
252 convert_to_wav 50c "$raw_eopt" "$wav_dopt"
253 convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
254 convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
255 convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
256 convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
257 convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
258 convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
259 convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
260 convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
261 convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
262 convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
263 convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
264 convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
265 convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
266 convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
267 convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
271 run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
272 run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
274 convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
275 convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
276 convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
277 convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
278 convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
279 convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
280 convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
281 convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
282 convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
283 convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
284 convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
285 convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
286 convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
287 convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
288 convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
289 convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
296 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
298 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
300 if [ $in_fmt = raw ] ; then
308 if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
314 if [ $out_fmt = ogg ] ; then
319 # test --skip when encoding
322 desc="($in_fmt<->$out_fmt)"
324 echo -n "testing --skip=# (encode) $desc... "
325 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
326 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
327 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
328 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
331 echo -n "testing --skip=mm:ss (encode) $desc... "
332 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
333 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
334 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
335 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
338 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
339 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
340 [ $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"
341 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
342 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
346 # test --skip when decoding
349 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"
351 echo -n "testing --skip=# (decode) $desc... "
352 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
353 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
354 rm -f z50c.skip10.$in_fmt
357 echo -n "testing --skip=mm:ss (decode) $desc... "
358 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
359 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
360 rm -f z50c.skip0:01.$in_fmt
363 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
364 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
365 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
366 rm -f z50c.skip0:01.1001.$in_fmt
372 # test --until when encoding
375 echo -n "testing --until=# (encode) $desc... "
376 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
377 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
378 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
379 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
382 echo -n "testing --until=mm:ss (encode) $desc... "
383 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
384 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
385 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
386 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
389 echo -n "testing --until=mm:ss.sss (encode) $desc... "
390 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
391 [ $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"
392 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
393 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
396 echo -n "testing --until=-# (encode) $desc... "
397 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
398 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
399 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
400 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
403 echo -n "testing --until=-mm:ss (encode) $desc... "
404 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
405 [ $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"
406 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
407 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
410 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
411 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
412 [ $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"
413 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
414 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
418 # test --until when decoding
421 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"
423 echo -n "testing --until=# (decode) $desc... "
424 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
425 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
426 rm -f z50c.until40.$in_fmt
429 echo -n "testing --until=mm:ss (decode) $desc... "
430 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
431 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
432 rm -f z50c.until0:04.$in_fmt
435 echo -n "testing --until=mm:ss.sss (decode) $desc... "
436 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
437 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
438 rm -f z50c.until0:03.9001.$in_fmt
441 echo -n "testing --until=-# (decode) $desc... "
442 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
443 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
444 rm -f z50c.until-10.$in_fmt
447 echo -n "testing --until=-mm:ss (decode) $desc... "
448 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$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 (decode) $desc"
450 rm -f z50c.until-0:01.$in_fmt
453 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
454 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
455 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
456 rm -f z50c.until-0:01.1001.$in_fmt
462 # test --skip and --until when encoding
465 echo -n "testing --skip=10 --until=# (encode) $desc... "
466 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
467 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
468 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
469 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
472 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
473 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
474 [ $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"
475 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
476 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
479 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
480 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"
481 [ $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"
482 $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"
483 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
486 echo -n "testing --skip=10 --until=+# (encode) $desc... "
487 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
488 [ $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"
489 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
490 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
493 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
494 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"
495 [ $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"
496 $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"
497 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
500 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
501 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"
502 [ $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"
503 $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"
504 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
507 echo -n "testing --skip=10 --until=-# (encode) $desc... "
508 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
509 [ $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"
510 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
511 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
514 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
515 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"
516 [ $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"
517 $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"
518 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
521 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
522 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"
523 [ $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"
524 $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"
525 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
529 # test --skip and --until when decoding
532 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"
535 echo -n "testing --skip=10 --until=# (decode) $desc... "
536 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
537 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
538 rm -f z50c.skip10.until40.$in_fmt
541 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
542 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
543 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
544 rm -f z50c.skip10.until0:04.$in_fmt
547 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
548 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"
549 $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"
550 rm -f z50c.skip10.until0:03.9001.$in_fmt
553 echo -n "testing --skip=10 --until=-# (decode) $desc... "
554 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
555 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
556 rm -f z50c.skip10.until-10.$in_fmt
559 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
560 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"
561 $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"
562 rm -f z50c.skip10.until-0:01.$in_fmt
565 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
566 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"
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 (decode) $desc"
568 rm -f z50c.skip10.until-0:01.1001.$in_fmt
574 test_skip_until raw flac
575 test_skip_until wav flac
576 test_skip_until aiff flac
577 test_skip_until flac flac
579 if [ $has_ogg = "yes" ] ; then
580 test_skip_until raw ogg
581 test_skip_until wav ogg
582 test_skip_until aiff ogg
583 #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
584 #@@@test_skip_until flac ogg
587 echo "testing seek extremes:"
589 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"
591 if [ $is_win = no ] ; then
592 total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
593 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
595 # some flavors of cygwin don't seem to treat the \x0d as a word
596 # separator, so we hard code it. we'll just have to fix it later
597 # if we change the way noise.flac is made.
598 total_noise_cdda_samples=393216
601 echo -n "testing --skip=0... "
602 run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
605 for delta in 2 1 ; do
606 n=`expr $total_noise_cdda_samples - $delta`
607 echo -n "testing --skip=$n... "
608 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
615 ############################################################################
617 ############################################################################
619 #@@@ cat will not work on old cygwin, need to fix
620 if [ $is_win = no ] ; then
621 echo -n "testing --input-size=50 --skip=10... "
622 cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
623 run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
624 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
625 rm -f z50c.skip10.raw z50c.skip10.flac
630 ############################################################################
632 ############################################################################
635 # create the cue sheet
638 cat > $cuesheet << EOF
639 CATALOG 1234567890123
656 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
658 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
660 if [ $in_fmt = raw ] ; then
668 if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
674 if [ $out_fmt = ogg ] ; then
678 desc="($in_fmt<->$out_fmt)"
681 # for this we need just need just one FLAC file; --cue only works while decoding
683 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
685 # To make it easy to translate from cue point to sample numbers, the
686 # file has a sample rate of 10 Hz and a cuesheet like so:
688 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
689 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
690 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
691 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
692 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
694 echo -n "testing --cue=- $desc... "
695 run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
696 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
697 rm -f z50c.cued.$in_fmt
700 echo -n "testing --cue=1.0 $desc... "
701 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
702 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
703 rm -f z50c.cued.$in_fmt
706 echo -n "testing --cue=1.0- $desc... "
707 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
708 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
709 rm -f z50c.cued.$in_fmt
712 echo -n "testing --cue=1.1 $desc... "
713 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
714 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
715 rm -f z50c.cued.$in_fmt
718 echo -n "testing --cue=1.1- $desc... "
719 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
720 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
721 rm -f z50c.cued.$in_fmt
724 echo -n "testing --cue=1.2 $desc... "
725 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
726 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
727 rm -f z50c.cued.$in_fmt
730 echo -n "testing --cue=1.2- $desc... "
731 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
732 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
733 rm -f z50c.cued.$in_fmt
736 echo -n "testing --cue=1.4 $desc... "
737 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
738 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
739 rm -f z50c.cued.$in_fmt
742 echo -n "testing --cue=1.4- $desc... "
743 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
744 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
745 rm -f z50c.cued.$in_fmt
748 echo -n "testing --cue=-5.0 $desc... "
749 run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.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=-5.0 $desc"
751 rm -f z50c.cued.$in_fmt
754 echo -n "testing --cue=-4.1 $desc... "
755 run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
756 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
757 rm -f z50c.cued.$in_fmt
760 echo -n "testing --cue=-3.1 $desc... "
761 run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
762 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
763 rm -f z50c.cued.$in_fmt
766 echo -n "testing --cue=-1.4 $desc... "
767 run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
768 $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
769 rm -f z50c.cued.$in_fmt
772 echo -n "testing --cue=1.0-5.0 $desc... "
773 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
774 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
775 rm -f z50c.cued.$in_fmt
778 echo -n "testing --cue=1.1-5.0 $desc... "
779 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
780 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
781 rm -f z50c.cued.$in_fmt
784 echo -n "testing --cue=1.2-4.1 $desc... "
785 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
786 $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
787 rm -f z50c.cued.$in_fmt
790 echo -n "testing --cue=1.4-2.0 $desc... "
791 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
792 $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
793 rm -f z50c.cued.$in_fmt
796 rm -f z50c.cue.$out_fmt
804 if [ $has_ogg = "yes" ] ; then
808 #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
809 #@@@test_cue flac ogg
812 ############################################################################
813 # test 'fixup' code that happens when a FLAC file with total_samples == 0
814 # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
815 # decoder go back and fix up the chunk headers
816 ############################################################################
818 echo -n "WAVE fixup test... "
820 echo -n "prepare... "
821 convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
824 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
825 # binary-mode stdin problem, so we use an undocumented option to metaflac to
826 # set the total sample count to 0
827 if [ $is_win = yes ] ; then
828 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
829 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
831 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
835 run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
837 echo -n "compare... "
838 cmp noise.wav fixup.wav || die "ERROR: file mismatch"
841 rm -f noise.wav fixup.wav fixup.flac
843 echo -n "AIFF fixup test... "
845 echo -n "prepare... "
846 convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
849 # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
850 # binary-mode stdin problem, so we use an undocumented option to metaflac to
851 # set the total sample count to 0
852 if [ $is_win = yes ] ; then
853 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
854 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
856 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
860 run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
862 echo -n "compare... "
863 cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
866 rm -f noise.aiff fixup.aiff fixup.flac
869 ############################################################################
871 ############################################################################
873 echo "Generating multiple input files from noise..."
874 multifile_format_decode="--endian=big --sign=signed"
875 multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2"
876 short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
877 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"
878 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
879 run_flac --decode --force $SILENT shortnoise.flac || die "ERROR generating WAVE file"
880 run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
881 cp shortnoise.flac file0.flac
882 cp shortnoise.flac file1.flac
883 cp shortnoise.flac file2.flac
884 rm -f shortnoise.flac
885 cp shortnoise.wav file0.wav
886 cp shortnoise.wav file1.wav
887 cp shortnoise.wav file2.wav
889 cp shortnoise.aiff file0.aiff
890 cp shortnoise.aiff file1.aiff
891 cp shortnoise.aiff file2.aiff
892 rm -f shortnoise.aiff
893 cp shortnoise.raw file0.raw
894 cp shortnoise.raw file1.raw
895 cp shortnoise.raw file2.raw
897 # create authoritative sector-aligned files for comparison
898 file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
899 file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
900 file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
901 file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
902 file1_samples=`expr $file1_samples - $file0_remainder`
903 file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
904 file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
905 file2_samples=`expr $file2_samples - $file1_remainder`
906 if [ $file2_remainder != '0' ] ; then
907 file2_samples=`expr $file2_samples + $file2_remainder`
908 file2_remainder=`expr 588 - $file2_remainder`
911 dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
912 dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
913 dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
914 cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
915 dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
916 dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
917 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
918 dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
919 cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
922 convert_to_wav file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
923 convert_to_wav file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
924 convert_to_wav file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
926 convert_to_aiff file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
927 convert_to_aiff file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
928 convert_to_aiff file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
937 extra_encode_options=""
938 extra_decode_options=""
939 if [ $input_type = "raw" ] ; then
940 extra_encode_options="--force-raw-format $multifile_format_encode"
941 extra_decode_options="--force-raw-format $multifile_format_decode"
943 if [ $input_type = "aiff" ] ; then
944 extra_decode_options="--force-aiff-format"
948 if [ $streamtype = ogg ] ; then
950 encode_options="$encode_options --ogg"
955 if [ $sector_align = sector_align ] ; then
956 encode_options="$encode_options --sector-align"
959 if [ $input_type = flac ] ; then
966 cp file$n.$input_type file${n}x.$input_type
968 run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
969 run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
970 if [ $sector_align != sector_align ] ; then
972 $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
976 $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
980 rm -f file${n}x.$suffix file${n}x.$input_type
984 for input_type in raw wav aiff flac ; do
985 echo "Testing multiple $input_type files without verify..."
986 test_multifile $input_type flac no_sector_align ""
988 echo "Testing multiple $input_type files with verify..."
989 test_multifile $input_type flac no_sector_align "--verify"
991 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
992 echo "Testing multiple $input_type files with --sector-align, without verify..."
993 test_multifile $input_type flac sector_align ""
995 echo "Testing multiple $input_type files with --sector-align, with verify..."
996 test_multifile $input_type flac sector_align "--verify"
999 if [ $has_ogg = "yes" ] ; then
1000 echo "Testing multiple $input_type files with --ogg, without verify..."
1001 test_multifile $input_type ogg no_sector_align ""
1003 echo "Testing multiple $input_type files with --ogg, with verify..."
1004 test_multifile $input_type ogg no_sector_align "--verify"
1006 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
1007 echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
1008 test_multifile $input_type ogg sector_align ""
1010 echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
1011 test_multifile $input_type ogg sector_align "--verify"
1014 echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
1015 test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
1020 ############################################################################
1021 # test the metadata-handling properties of flac-to-flac encoding
1022 ############################################################################
1024 echo "Testing the metadata-handling properties of flac-to-flac encoding..."
1026 testdir="flac-to-flac-metadata-test-files"
1029 # minor danger, changing vendor strings will change the length of the
1030 # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
1031 # we lose info about PADDING size that we need
1032 grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
1039 expect="$case-expect.meta"
1041 run_flac $SILENT -f -o out.flac $args $file || die "ERROR encoding FLAC file"
1042 run_metaflac --list out.flac | filter > out.meta || die "ERROR listing metadata of output FLAC file"
1043 diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
1047 #filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
1048 cd $testdir || die "ERROR changing to directory $testdir"
1050 # case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
1051 flac2flac input-SCVAUP.flac case00a ""
1052 # case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
1053 flac2flac input-SCVPAP.flac case01a ""
1054 # case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
1055 flac2flac input-SCVPAP.flac case01b "--no-padding"
1056 # case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
1057 flac2flac input-SCVPAP.flac case01c "-P 1234"
1058 # case 01d: on file with no PADDING blocks, use -P setting
1059 flac2flac input-SCVA.flac case01d "-P 1234"
1060 # case 01e: on file with no PADDING blocks and no -P given, use default padding
1061 flac2flac input-SCVA.flac case01e ""
1062 # case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
1063 flac2flac input-SCPAP.flac case02a ""
1064 # case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
1065 flac2flac input-SCPAP.flac case02b "--tag=artist=0"
1066 # case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
1067 flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
1068 # case 03a: on file with no CUESHEET block and --cuesheet specified, add it
1069 flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
1070 # case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
1071 flac2flac input-SCVAUP.flac case03b "$TOTALLY_SILENT --cuesheet=input0.cue"
1072 # case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
1073 flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
1074 # case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
1075 flac2flac input-VA.flac case04a "--no-padding --no-seektable"
1076 # case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
1077 flac2flac input-VA.flac case04b "--no-padding -S 5x"
1078 # case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
1079 flac2flac input-VA.flac case04c "--no-padding"
1080 # case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
1081 flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
1082 # case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
1083 flac2flac input-SCVA.flac case04e "$TOTALLY_SILENT --no-padding -S 5x"
1084 # case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
1085 #(already covered by case03c)
1087 rm -f out.flac out.meta