blob: af916ead54250146b252055903996f509a130018 [file] [log] [blame]
Josh Coalson463d0f82002-12-10 06:41:27 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
Josh Coalsone74bd952007-02-02 06:58:19 +00004# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Josh Coalson463d0f82002-12-10 06:41:27 +00005#
Josh Coalsone8a76012003-02-07 00:14:32 +00006# 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
13# distributed.
Josh Coalson463d0f82002-12-10 06:41:27 +000014#
Josh Coalsone8a76012003-02-07 00:14:32 +000015# 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
18# distribution.
Josh Coalson463d0f82002-12-10 06:41:27 +000019
Josh Coalson8fac5d62002-12-12 03:57:47 +000020die ()
21{
22 echo $* 1>&2
23 exit 1
24}
25
Josh Coalson1d42ba62006-11-08 16:25:55 +000026dddie="die ERROR: creating files with dd"
27
Josh Coalsonbfda3782006-08-28 03:42:10 +000028if [ x = x"$1" ] ; then
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000029 BUILD=debug
30else
31 BUILD="$1"
32fi
33
Josh Coalsonbfda3782006-08-28 03:42:10 +000034# change to 'false' to show flac output (useful for debugging)
35if true ; then
36 SILENT='--silent'
37 TOTALLY_SILENT='--totally-silent'
38else
39 SILENT=''
40 TOTALLY_SILENT=''
41fi
42
43LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
Josh Coalsonbfda3782006-08-28 03:42:10 +000044LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
45LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
46LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
47LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
48LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
49LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
Josh Coalson463d0f82002-12-10 06:41:27 +000050export LD_LIBRARY_PATH
Josh Coalsonbfda3782006-08-28 03:42:10 +000051PATH=`pwd`/../src/flac:$PATH
52PATH=`pwd`/../src/metaflac:$PATH
53PATH=`pwd`/../src/test_streams:$PATH
54PATH=`pwd`/../obj/$BUILD/bin:$PATH
Josh Coalson463d0f82002-12-10 06:41:27 +000055
Josh Coalson8fac5d62002-12-12 03:57:47 +000056flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalson463d0f82002-12-10 06:41:27 +000057
58run_flac ()
59{
Josh Coalsonde9091e2006-05-25 02:48:22 +000060 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson8ebb95c2006-11-20 05:29:59 +000061 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_flac.valgrind.log
Josh Coalson89f01a82007-06-20 01:26:29 +000062 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 flac $* 4>>test_flac.valgrind.log
Josh Coalson463d0f82002-12-10 06:41:27 +000063 else
64 flac $*
65 fi
66}
67
Josh Coalson68d13212004-09-14 00:25:43 +000068run_metaflac ()
69{
Josh Coalsonde9091e2006-05-25 02:48:22 +000070 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson8ebb95c2006-11-20 05:29:59 +000071 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 metaflac $*" >>test_flac.valgrind.log
Josh Coalson89f01a82007-06-20 01:26:29 +000072 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 metaflac $* 4>>test_flac.valgrind.log
Josh Coalson68d13212004-09-14 00:25:43 +000073 else
74 metaflac $*
75 fi
76}
77
Josh Coalsonbfda3782006-08-28 03:42:10 +000078md5cmp ()
79{
80 #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`
81 n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
82 [ "$n" != "" ] && [ $n = 1 ]
83}
84
Josh Coalsond4346722004-09-12 22:58:13 +000085if [ `env | grep -ic '^comspec='` != 0 ] ; then
86 is_win=yes
87else
88 is_win=no
89fi
90
Josh Coalson463d0f82002-12-10 06:41:27 +000091echo "Checking for --ogg support in flac..."
Josh Coalsonbfda3782006-08-28 03:42:10 +000092if 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
Josh Coalson463d0f82002-12-10 06:41:27 +000093 has_ogg=yes;
94 echo "flac --ogg works"
95else
96 has_ogg=no;
97 echo "flac --ogg doesn't work"
98fi
99
Josh Coalson5126bb02002-12-17 08:15:48 +0000100echo "Generating streams..."
101if [ ! -f wacky1.wav ] ; then
102 test_streams || die "ERROR during test_streams"
103fi
104
105############################################################################
Josh Coalson0bb57d02004-07-16 00:50:42 +0000106# test that flac doesn't automatically overwrite files unless -f is used
107############################################################################
108
109echo "Try encoding to a file that exists; should fail"
110cp wacky1.wav exist.wav
111touch exist.flac
Josh Coalsonbfda3782006-08-28 03:42:10 +0000112if run_flac $TOTALLY_SILENT -0 exist.wav ; then
Josh Coalson0bb57d02004-07-16 00:50:42 +0000113 die "ERROR: it should have failed but didn't"
114else
115 echo "OK, it failed as it should"
116fi
117
118echo "Try encoding with -f to a file that exists; should succeed"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000119if run_flac $TOTALLY_SILENT -0 --force exist.wav ; then
Josh Coalson0bb57d02004-07-16 00:50:42 +0000120 echo "OK, it succeeded as it should"
121else
122 die "ERROR: it should have succeeded but didn't"
123fi
124
125echo "Try decoding to a file that exists; should fail"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000126if run_flac $TOTALLY_SILENT -d exist.flac ; then
Josh Coalson0bb57d02004-07-16 00:50:42 +0000127 die "ERROR: it should have failed but didn't"
128else
129 echo "OK, it failed as it should"
130fi
131
132echo "Try decoding with -f to a file that exists; should succeed"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000133if run_flac $TOTALLY_SILENT -d -f exist.flac ; then
Josh Coalson0bb57d02004-07-16 00:50:42 +0000134 echo "OK, it succeeded as it should"
135else
136 die "ERROR: it should have succeeded but didn't"
137fi
138
139rm -f exist.wav exist.flac
140
141############################################################################
Josh Coalson1d42ba62006-11-08 16:25:55 +0000142# test fractional block sizes
143############################################################################
144
Josh Coalsonacc4bea2006-11-09 16:53:15 +0000145test_fractional ()
146{
147 blocksize=$1
148 samples=$2
Josh Coalson1d42ba62006-11-08 16:25:55 +0000149 dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie
Josh Coalsonacc4bea2006-11-09 16:53:15 +0000150 echo -n "fractional block size test (blocksize=$blocksize samples=$samples) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000151 run_flac $SILENT --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=$blocksize --no-padding --lax -o pbs.flac pbs.raw || die "ERROR"
Josh Coalson1d42ba62006-11-08 16:25:55 +0000152 echo -n "decode... "
153 run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o pbs.cmp pbs.flac || die "ERROR"
154 echo -n "compare... "
155 cmp pbs.raw pbs.cmp || die "ERROR: file mismatch"
156 echo "OK"
157 rm -f pbs.raw pbs.flac pbs.cmp
Josh Coalsonacc4bea2006-11-09 16:53:15 +0000158}
159
160# The special significance of 2048 is it's the # of samples that flac calls
161# FLAC__stream_encoder_process() on.
162#
163# We're trying to make sure the 1-sample overread logic in the stream encoder
164# (used for last-block checking) works; these values probe around common
165# multiples of the flac sample chunk size (2048) and the blocksize.
166for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do
167 test_fractional 33 $samples
168done
169for samples in 254 255 256 257 258 510 511 512 513 514 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
170 test_fractional 256 $samples
171done
172for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
173 test_fractional 2048 $samples
174done
175for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 4606 4607 4608 4609 4610 8190 8191 8192 8193 8194 16382 16383 16384 16385 16386 ; do
176 test_fractional 4608 $samples
Josh Coalson1d42ba62006-11-08 16:25:55 +0000177done
178
179############################################################################
Josh Coalson5126bb02002-12-17 08:15:48 +0000180# basic 'round-trip' tests of various kinds of streams
181############################################################################
182
183rt_test_raw ()
184{
185 f="$1"
186 channels=`echo $f | awk -F- '{print $2}'`
Josh Coalson8def87a2006-10-07 01:20:38 +0000187 bps=`echo $f | awk -F- '{print $3}'`
Josh Coalson5126bb02002-12-17 08:15:48 +0000188 echo -n "round-trip test ($f) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000189 run_flac $SILENT --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels --no-padding --lax -o rt.flac $f || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000190 echo -n "decode... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000191 run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000192 echo -n "compare... "
193 cmp $f rt.raw || die "ERROR: file mismatch"
194 echo "OK"
195 rm -f rt.flac rt.raw
196}
197
198rt_test_wav ()
199{
200 f="$1"
201 echo -n "round-trip test ($f) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000202 run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000203 echo -n "decode... "
Josh Coalsoncc5c1d82006-10-06 05:31:27 +0000204 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt.flac || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000205 echo -n "compare... "
206 cmp $f rt.wav || die "ERROR: file mismatch"
207 echo "OK"
208 rm -f rt.flac rt.wav
209}
210
211rt_test_aiff ()
212{
213 f="$1"
214 echo -n "round-trip test ($f) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000215 run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000216 echo -n "decode... "
Josh Coalsoncc5c1d82006-10-06 05:31:27 +0000217 run_flac $SILENT --force --decode --channel-map=none -o rt.aiff rt.flac || die "ERROR"
Josh Coalson5126bb02002-12-17 08:15:48 +0000218 echo -n "compare... "
219 cmp $f rt.aiff || die "ERROR: file mismatch"
220 echo "OK"
221 rm -f rt.flac rt.aiff
222}
223
Josh Coalsonbfda3782006-08-28 03:42:10 +0000224# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
225rt_test_flac ()
226{
227 f="$1"
228 echo -n "round-trip test ($f->flac->flac->wav) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000229 run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000230 echo -n "re-encode... "
Josh Coalson8def87a2006-10-07 01:20:38 +0000231 run_flac $SILENT --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000232 echo -n "decode... "
Josh Coalsoncc5c1d82006-10-06 05:31:27 +0000233 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.flac || die "ERROR"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000234 echo -n "compare... "
235 cmp $f rt.wav || die "ERROR: file mismatch"
236 echo "OK"
237 rm -f rt.wav rt.flac rt2.flac
238}
239
Josh Coalsonc28efe22006-11-04 03:04:21 +0000240# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
241rt_test_ogg_flac ()
242{
243 f="$1"
244 echo -n "round-trip test ($f->oggflac->oggflac->wav) encode... "
Josh Coalson5ebd6932006-11-17 06:03:18 +0000245 run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.ogg --ogg $f || die "ERROR"
Josh Coalsonc28efe22006-11-04 03:04:21 +0000246 echo -n "re-encode... "
247 run_flac $SILENT --force --verify --lax -o rt2.ogg --ogg rt.ogg || die "ERROR"
248 echo -n "decode... "
249 run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.ogg || die "ERROR"
250 echo -n "compare... "
251 cmp $f rt.wav || die "ERROR: file mismatch"
252 echo "OK"
253 rm -f rt.wav rt.ogg rt2.ogg
254}
255
Josh Coalson5126bb02002-12-17 08:15:48 +0000256for f in rt-*.raw ; do
257 rt_test_raw $f
258done
259for f in rt-*.wav ; do
260 rt_test_wav $f
261done
262for f in rt-*.aiff ; do
263 rt_test_aiff $f
264done
Josh Coalsonbfda3782006-08-28 03:42:10 +0000265for f in rt-*.wav ; do
266 rt_test_flac $f
267done
Josh Coalsonc28efe22006-11-04 03:04:21 +0000268if [ $has_ogg = yes ] ; then
269 for f in rt-*.wav ; do
270 rt_test_ogg_flac $f
271 done
272fi
Josh Coalson5126bb02002-12-17 08:15:48 +0000273
Josh Coalson8fac5d62002-12-12 03:57:47 +0000274############################################################################
275# test --skip and --until
276############################################################################
277
Josh Coalson463d0f82002-12-10 06:41:27 +0000278#
Josh Coalson8232e292002-12-14 06:22:22 +0000279# first make some chopped-up raw files
Josh Coalson463d0f82002-12-10 06:41:27 +0000280#
Josh Coalson8fac5d62002-12-12 03:57:47 +0000281echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
Josh Coalson8fac5d62002-12-12 03:57:47 +0000282dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
283dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
284dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
Josh Coalson03a5a692004-07-17 00:23:17 +0000285dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
286dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
287dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
288dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
289dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
290dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
Josh Coalson8fac5d62002-12-12 03:57:47 +0000291dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
Josh Coalson03a5a692004-07-17 00:23:17 +0000292dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
293dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
Josh Coalson8fac5d62002-12-12 03:57:47 +0000294dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
Josh Coalson03a5a692004-07-17 00:23:17 +0000295dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
296dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
297dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
Josh Coalson463d0f82002-12-10 06:41:27 +0000298
Josh Coalson5ebd6932006-11-17 06:03:18 +0000299wav_eopt="$SILENT --force --verify --no-padding --lax"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000300wav_dopt="$SILENT --force --decode"
Josh Coalson8232e292002-12-14 06:22:22 +0000301
Josh Coalson2b295462006-11-17 07:26:39 +0000302raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
Josh Coalson8232e292002-12-14 06:22:22 +0000303raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000304
305#
Josh Coalsonc28efe22006-11-04 03:04:21 +0000306# convert them to WAVE/AIFF/Ogg FLAC files
Josh Coalson8fac5d62002-12-12 03:57:47 +0000307#
Josh Coalson8232e292002-12-14 06:22:22 +0000308convert_to_wav ()
309{
Josh Coalsonc2751e62005-08-27 01:57:39 +0000310 run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
311 run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
Josh Coalson8232e292002-12-14 06:22:22 +0000312}
Josh Coalsonc2751e62005-08-27 01:57:39 +0000313convert_to_wav 50c "$raw_eopt" "$wav_dopt"
314convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
315convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
316convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
317convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
318convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
319convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
320convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
321convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
322convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
323convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
324convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
325convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
326convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
327convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
328convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000329
Josh Coalson5126bb02002-12-17 08:15:48 +0000330convert_to_aiff ()
331{
Josh Coalsonc2751e62005-08-27 01:57:39 +0000332 run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
333 run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
Josh Coalson5126bb02002-12-17 08:15:48 +0000334}
Josh Coalsonc2751e62005-08-27 01:57:39 +0000335convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
336convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
337convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
338convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
339convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
340convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
341convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
342convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
343convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
344convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
345convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
346convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
347convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
348convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
349convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
350convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
Josh Coalson5126bb02002-12-17 08:15:48 +0000351
Josh Coalsonc28efe22006-11-04 03:04:21 +0000352convert_to_ogg ()
353{
354 run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
355}
356if [ $has_ogg = yes ] ; then
357 convert_to_ogg 50c
358 convert_to_ogg 50c.skip10
359 convert_to_ogg 50c.skip11
360 convert_to_ogg 50c.skip20
361 convert_to_ogg 50c.skip30
362 convert_to_ogg 50c.skip40
363 convert_to_ogg 50c.until10
364 convert_to_ogg 50c.until20
365 convert_to_ogg 50c.until30
366 convert_to_ogg 50c.until39
367 convert_to_ogg 50c.until40
368 convert_to_ogg 50c.skip10.until30
369 convert_to_ogg 50c.skip10.until39
370 convert_to_ogg 50c.skip10.until40
371 convert_to_ogg 50c.skip20.until30
372 convert_to_ogg 50c.skip20.until40
373fi
374
Josh Coalson8232e292002-12-14 06:22:22 +0000375test_skip_until ()
376{
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000377 in_fmt=$1
378 out_fmt=$2
Josh Coalson463d0f82002-12-10 06:41:27 +0000379
Josh Coalsonc28efe22006-11-04 03:04:21 +0000380 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
Josh Coalson463d0f82002-12-10 06:41:27 +0000381
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000382 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
383
384 if [ $in_fmt = raw ] ; then
Josh Coalson8232e292002-12-14 06:22:22 +0000385 eopt="$raw_eopt"
386 dopt="$raw_dopt"
387 else
388 eopt="$wav_eopt"
389 dopt="$wav_dopt"
390 fi
Josh Coalson463d0f82002-12-10 06:41:27 +0000391
Josh Coalsonc28efe22006-11-04 03:04:21 +0000392 if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
Josh Coalsonbfda3782006-08-28 03:42:10 +0000393 CMP=md5cmp
394 else
395 CMP=cmp
396 fi
397
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000398 if [ $out_fmt = ogg ] ; then
399 eopt="--ogg $eopt"
400 fi
401
Josh Coalson8232e292002-12-14 06:22:22 +0000402 #
403 # test --skip when encoding
404 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000405
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000406 desc="($in_fmt<->$out_fmt)"
407
408 echo -n "testing --skip=# (encode) $desc... "
409 run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000410 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
411 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000412 rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000413 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000414
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000415 echo -n "testing --skip=mm:ss (encode) $desc... "
416 run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000417 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
418 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000419 rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000420 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000421
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000422 echo -n "testing --skip=mm:ss.sss (encode) $desc... "
423 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000424 [ $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"
425 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000426 rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000427 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000428
Josh Coalson8232e292002-12-14 06:22:22 +0000429 #
430 # test --skip when decoding
431 #
Josh Coalson463d0f82002-12-10 06:41:27 +0000432
Josh Coalsonbfda3782006-08-28 03:42:10 +0000433 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"
434
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000435 echo -n "testing --skip=# (decode) $desc... "
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000436 run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000437 $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000438 rm -f z50c.skip10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000439 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000440
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000441 echo -n "testing --skip=mm:ss (decode) $desc... "
442 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000443 $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000444 rm -f z50c.skip0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000445 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000446
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000447 echo -n "testing --skip=mm:ss.sss (decode) $desc... "
448 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000449 $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000450 rm -f z50c.skip0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000451 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000452
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000453 rm -f z50c.$out_fmt
Josh Coalson8fac5d62002-12-12 03:57:47 +0000454
Josh Coalson8232e292002-12-14 06:22:22 +0000455 #
456 # test --until when encoding
457 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000458
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000459 echo -n "testing --until=# (encode) $desc... "
460 run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000461 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
462 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000463 rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000464 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000465
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000466 echo -n "testing --until=mm:ss (encode) $desc... "
467 run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000468 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
469 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000470 rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000471 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000472
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000473 echo -n "testing --until=mm:ss.sss (encode) $desc... "
474 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000475 [ $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"
476 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000477 rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000478 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000479
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000480 echo -n "testing --until=-# (encode) $desc... "
481 run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000482 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
483 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000484 rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000485 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000486
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000487 echo -n "testing --until=-mm:ss (encode) $desc... "
488 run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000489 [ $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"
490 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000491 rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000492 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000493
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000494 echo -n "testing --until=-mm:ss.sss (encode) $desc... "
495 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000496 [ $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"
497 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000498 rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000499 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000500
Josh Coalson8232e292002-12-14 06:22:22 +0000501 #
502 # test --until when decoding
503 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000504
Josh Coalsonbfda3782006-08-28 03:42:10 +0000505 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"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000506
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000507 echo -n "testing --until=# (decode) $desc... "
508 run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000509 $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000510 rm -f z50c.until40.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000511 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000512
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000513 echo -n "testing --until=mm:ss (decode) $desc... "
514 run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000515 $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000516 rm -f z50c.until0:04.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000517 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000518
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000519 echo -n "testing --until=mm:ss.sss (decode) $desc... "
520 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000521 $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000522 rm -f z50c.until0:03.9001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000523 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000524
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000525 echo -n "testing --until=-# (decode) $desc... "
526 run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000527 $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000528 rm -f z50c.until-10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000529 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000530
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000531 echo -n "testing --until=-mm:ss (decode) $desc... "
532 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000533 $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000534 rm -f z50c.until-0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000535 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000536
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000537 echo -n "testing --until=-mm:ss.sss (decode) $desc... "
538 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000539 $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000540 rm -f z50c.until-0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000541 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000542
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000543 rm -f z50c.$out_fmt
Josh Coalson8fac5d62002-12-12 03:57:47 +0000544
Josh Coalson8232e292002-12-14 06:22:22 +0000545 #
546 # test --skip and --until when encoding
547 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000548
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000549 echo -n "testing --skip=10 --until=# (encode) $desc... "
550 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000551 [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
552 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000553 rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000554 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000555
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000556 echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
557 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000558 [ $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"
559 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000560 rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000561 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000562
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000563 echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
564 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000565 [ $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"
566 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000567 rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000568 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000569
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000570 echo -n "testing --skip=10 --until=+# (encode) $desc... "
571 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000572 [ $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"
573 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000574 rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000575 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000576
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000577 echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
578 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000579 [ $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"
580 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000581 rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000582 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000583
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000584 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
585 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000586 [ $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"
587 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000588 rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000589 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000590
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000591 echo -n "testing --skip=10 --until=-# (encode) $desc... "
592 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000593 [ $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"
594 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000595 rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000596 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000597
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000598 echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
599 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000600 [ $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"
601 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000602 rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000603 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000604
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000605 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
606 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000607 [ $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"
608 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000609 rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000610 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000611
Josh Coalson8232e292002-12-14 06:22:22 +0000612 #
613 # test --skip and --until when decoding
614 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000615
Josh Coalsonbfda3782006-08-28 03:42:10 +0000616 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"
617
Josh Coalson8fac5d62002-12-12 03:57:47 +0000618
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000619 echo -n "testing --skip=10 --until=# (decode) $desc... "
620 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000621 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000622 rm -f z50c.skip10.until40.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000623 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000624
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000625 echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
626 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000627 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000628 rm -f z50c.skip10.until0:04.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000629 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000630
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000631 echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
632 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000633 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000634 rm -f z50c.skip10.until0:03.9001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000635 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000636
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000637 echo -n "testing --skip=10 --until=-# (decode) $desc... "
638 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000639 $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000640 rm -f z50c.skip10.until-10.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000641 echo OK
642
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000643 echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
644 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000645 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000646 rm -f z50c.skip10.until-0:01.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000647 echo OK
648
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000649 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
650 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"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000651 $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"
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000652 rm -f z50c.skip10.until-0:01.1001.$in_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000653 echo OK
654
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000655 rm -f z50c.$out_fmt
Josh Coalson8232e292002-12-14 06:22:22 +0000656}
657
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000658test_skip_until raw flac
659test_skip_until wav flac
660test_skip_until aiff flac
Josh Coalsonbfda3782006-08-28 03:42:10 +0000661test_skip_until flac flac
Josh Coalsonc28efe22006-11-04 03:04:21 +0000662#@@@if [ $has_ogg = yes ] ; then
663#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
664#@@@ test_skip_until ogg flac
665#@@@fi
Josh Coalson463d0f82002-12-10 06:41:27 +0000666
Josh Coalsonc28efe22006-11-04 03:04:21 +0000667if [ $has_ogg = yes ] ; then
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000668 test_skip_until raw ogg
669 test_skip_until wav ogg
670 test_skip_until aiff ogg
Josh Coalsonc28efe22006-11-04 03:04:21 +0000671 #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
Josh Coalsonbfda3782006-08-28 03:42:10 +0000672 #@@@test_skip_until flac ogg
Josh Coalsonc28efe22006-11-04 03:04:21 +0000673 #@@@test_skip_until ogg ogg
Josh Coalson3e3ad0c2004-07-07 07:39:59 +0000674fi
Josh Coalson9238a142002-12-21 03:29:26 +0000675
Josh Coalson70d85632004-09-21 05:29:01 +0000676echo "testing seek extremes:"
Josh Coalson29f52ea2004-07-30 00:22:46 +0000677
Josh Coalson5ebd6932006-11-17 06:03:18 +0000678run_flac --verify --force $SILENT --no-padding --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 noise.raw || die "ERROR generating FLAC file"
Josh Coalson29f52ea2004-07-30 00:22:46 +0000679
Josh Coalsond4346722004-09-12 22:58:13 +0000680if [ $is_win = no ] ; then
Josh Coalsonc2751e62005-08-27 01:57:39 +0000681 total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
Josh Coalsond4346722004-09-12 22:58:13 +0000682 [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
683else
684 # some flavors of cygwin don't seem to treat the \x0d as a word
685 # separator, so we hard code it. we'll just have to fix it later
686 # if we change the way noise.flac is made.
Josh Coalsonc2751e62005-08-27 01:57:39 +0000687 total_noise_cdda_samples=393216
Josh Coalsond4346722004-09-12 22:58:13 +0000688fi
Josh Coalson29f52ea2004-07-30 00:22:46 +0000689
Josh Coalson70d85632004-09-21 05:29:01 +0000690echo -n "testing --skip=0... "
Josh Coalson4f4beee2004-07-30 00:35:51 +0000691run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
Josh Coalson29f52ea2004-07-30 00:22:46 +0000692echo OK
693
694for delta in 2 1 ; do
Josh Coalsonc2751e62005-08-27 01:57:39 +0000695 n=`expr $total_noise_cdda_samples - $delta`
Josh Coalson70d85632004-09-21 05:29:01 +0000696 echo -n "testing --skip=$n... "
Josh Coalson4f4beee2004-07-30 00:35:51 +0000697 run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
Josh Coalson29f52ea2004-07-30 00:22:46 +0000698 echo OK
699done
700
701rm noise.flac z.wav
702
703
Josh Coalson9238a142002-12-21 03:29:26 +0000704############################################################################
Josh Coalsondad6ad42004-12-30 03:49:46 +0000705# test --input-size
706############################################################################
707
Josh Coalsonc0da1962006-09-16 00:07:20 +0000708#@@@ cat will not work on old cygwin, need to fix
Josh Coalson47a6b5f2005-02-02 01:50:47 +0000709if [ $is_win = no ] ; then
710 echo -n "testing --input-size=50 --skip=10... "
711 cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
712 run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
713 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
714 rm -f z50c.skip10.raw z50c.skip10.flac
715 echo OK
716fi
Josh Coalsondad6ad42004-12-30 03:49:46 +0000717
718
719############################################################################
Josh Coalson03a5a692004-07-17 00:23:17 +0000720# test --cue
721############################################################################
722
723#
724# create the cue sheet
725#
726cuesheet=cuetest.cue
727cat > $cuesheet << EOF
728CATALOG 1234567890123
729FILE "blah" WAVE
730 TRACK 01 AUDIO
731 INDEX 01 0
732 INDEX 02 10
733 INDEX 03 20
734 TRACK 02 AUDIO
735 INDEX 01 30
736 TRACK 04 AUDIO
737 INDEX 01 40
738EOF
739
740test_cue ()
741{
742 in_fmt=$1
743 out_fmt=$2
744
Josh Coalsonc28efe22006-11-04 03:04:21 +0000745 [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
Josh Coalson03a5a692004-07-17 00:23:17 +0000746
747 [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
748
749 if [ $in_fmt = raw ] ; then
750 eopt="$raw_eopt"
751 dopt="$raw_dopt"
752 else
753 eopt="$wav_eopt"
754 dopt="$wav_dopt"
755 fi
756
Josh Coalsonc28efe22006-11-04 03:04:21 +0000757 if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
Josh Coalsonbfda3782006-08-28 03:42:10 +0000758 CMP=md5cmp
759 else
760 CMP=cmp
761 fi
762
Josh Coalson03a5a692004-07-17 00:23:17 +0000763 if [ $out_fmt = ogg ] ; then
764 eopt="--ogg $eopt"
765 fi
766
767 desc="($in_fmt<->$out_fmt)"
768
769 #
770 # for this we need just need just one FLAC file; --cue only works while decoding
771 #
772 run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
773
774 # To make it easy to translate from cue point to sample numbers, the
775 # file has a sample rate of 10 Hz and a cuesheet like so:
776 #
777 # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
778 # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
779 # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
780 # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
781 # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
782 #
783 echo -n "testing --cue=- $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000784 run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
785 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
786 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000787 echo OK
788
789 echo -n "testing --cue=1.0 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000790 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
791 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
792 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000793 echo OK
794
795 echo -n "testing --cue=1.0- $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000796 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
797 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
798 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000799 echo OK
800
801 echo -n "testing --cue=1.1 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000802 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
803 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
804 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000805 echo OK
806
807 echo -n "testing --cue=1.1- $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000808 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
809 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
810 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000811 echo OK
812
813 echo -n "testing --cue=1.2 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000814 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
815 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
816 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000817 echo OK
818
819 echo -n "testing --cue=1.2- $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000820 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
821 $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
822 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000823 echo OK
824
825 echo -n "testing --cue=1.4 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000826 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
827 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
828 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000829 echo OK
830
831 echo -n "testing --cue=1.4- $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000832 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
833 $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
834 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000835 echo OK
836
837 echo -n "testing --cue=-5.0 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000838 run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
839 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
840 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000841 echo OK
842
843 echo -n "testing --cue=-4.1 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000844 run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
845 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
846 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000847 echo OK
848
849 echo -n "testing --cue=-3.1 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000850 run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
851 $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
852 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000853 echo OK
854
855 echo -n "testing --cue=-1.4 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000856 run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
857 $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
858 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000859 echo OK
860
861 echo -n "testing --cue=1.0-5.0 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000862 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
863 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
864 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000865 echo OK
866
867 echo -n "testing --cue=1.1-5.0 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000868 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
869 $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
870 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000871 echo OK
872
873 echo -n "testing --cue=1.2-4.1 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000874 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
875 $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
876 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000877 echo OK
878
879 echo -n "testing --cue=1.4-2.0 $desc... "
Josh Coalsonbfda3782006-08-28 03:42:10 +0000880 run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
881 $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
882 rm -f z50c.cued.$in_fmt
Josh Coalson03a5a692004-07-17 00:23:17 +0000883 echo OK
884
885 rm -f z50c.cue.$out_fmt
886}
887
888test_cue raw flac
889test_cue wav flac
890test_cue aiff flac
Josh Coalsonbfda3782006-08-28 03:42:10 +0000891test_cue flac flac
Josh Coalsonc28efe22006-11-04 03:04:21 +0000892#@@@if [ $has_ogg = yes ] ; then
893#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
894#@@@ test_cue ogg flac
895#@@@fi
Josh Coalson03a5a692004-07-17 00:23:17 +0000896
Josh Coalsonc28efe22006-11-04 03:04:21 +0000897if [ $has_ogg = yes ] ; then
Josh Coalson03a5a692004-07-17 00:23:17 +0000898 test_cue raw ogg
899 test_cue wav ogg
900 test_cue aiff ogg
Josh Coalsonc28efe22006-11-04 03:04:21 +0000901 #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
Josh Coalsonbfda3782006-08-28 03:42:10 +0000902 #@@@test_cue flac ogg
Josh Coalsonc28efe22006-11-04 03:04:21 +0000903 #@@@test_cue ogg ogg
Josh Coalson03a5a692004-07-17 00:23:17 +0000904fi
905
906############################################################################
Josh Coalson9238a142002-12-21 03:29:26 +0000907# test 'fixup' code that happens when a FLAC file with total_samples == 0
908# in the STREAMINFO block is converted to WAVE or AIFF, requiring the
909# decoder go back and fix up the chunk headers
910############################################################################
911
912echo -n "WAVE fixup test... "
Josh Coalsond4346722004-09-12 22:58:13 +0000913
Josh Coalson9238a142002-12-21 03:29:26 +0000914echo -n "prepare... "
Josh Coalsonc2751e62005-08-27 01:57:39 +0000915convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
Josh Coalsond4346722004-09-12 22:58:13 +0000916
Josh Coalson9238a142002-12-21 03:29:26 +0000917echo -n "encode... "
Josh Coalsond4346722004-09-12 22:58:13 +0000918# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
919# binary-mode stdin problem, so we use an undocumented option to metaflac to
920# set the total sample count to 0
921if [ $is_win = yes ] ; then
922 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
Josh Coalson68d13212004-09-14 00:25:43 +0000923 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
Josh Coalsond4346722004-09-12 22:58:13 +0000924else
925 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
926fi
927
Josh Coalson9238a142002-12-21 03:29:26 +0000928echo -n "decode... "
929run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
Josh Coalsond4346722004-09-12 22:58:13 +0000930
Josh Coalson9238a142002-12-21 03:29:26 +0000931echo -n "compare... "
932cmp noise.wav fixup.wav || die "ERROR: file mismatch"
Josh Coalsond4346722004-09-12 22:58:13 +0000933
Josh Coalson9238a142002-12-21 03:29:26 +0000934echo OK
935rm -f noise.wav fixup.wav fixup.flac
936
937echo -n "AIFF fixup test... "
Josh Coalsond4346722004-09-12 22:58:13 +0000938
Josh Coalson9238a142002-12-21 03:29:26 +0000939echo -n "prepare... "
Josh Coalsonc2751e62005-08-27 01:57:39 +0000940convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
Josh Coalsond4346722004-09-12 22:58:13 +0000941
Josh Coalson9238a142002-12-21 03:29:26 +0000942echo -n "encode... "
Josh Coalsond4346722004-09-12 22:58:13 +0000943# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
944# binary-mode stdin problem, so we use an undocumented option to metaflac to
945# set the total sample count to 0
946if [ $is_win = yes ] ; then
947 run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
Josh Coalson68d13212004-09-14 00:25:43 +0000948 run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
Josh Coalsond4346722004-09-12 22:58:13 +0000949else
950 cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
951fi
952
Josh Coalson9238a142002-12-21 03:29:26 +0000953echo -n "decode... "
954run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
Josh Coalsond4346722004-09-12 22:58:13 +0000955
Josh Coalson9238a142002-12-21 03:29:26 +0000956echo -n "compare... "
957cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
Josh Coalsond4346722004-09-12 22:58:13 +0000958
Josh Coalson9238a142002-12-21 03:29:26 +0000959echo OK
960rm -f noise.aiff fixup.aiff fixup.flac
961
962
963############################################################################
Josh Coalson463d0f82002-12-10 06:41:27 +0000964# multi-file tests
Josh Coalson9238a142002-12-21 03:29:26 +0000965############################################################################
Josh Coalson463d0f82002-12-10 06:41:27 +0000966
Josh Coalson463d0f82002-12-10 06:41:27 +0000967echo "Generating multiple input files from noise..."
Josh Coalsonc2751e62005-08-27 01:57:39 +0000968multifile_format_decode="--endian=big --sign=signed"
Josh Coalson5ebd6932006-11-17 06:03:18 +0000969multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding"
Josh Coalsonbfda3782006-08-28 03:42:10 +0000970short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
971run_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"
972run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
973run_flac --decode --force $SILENT shortnoise.flac || die "ERROR generating WAVE file"
974run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
975cp shortnoise.flac file0.flac
976cp shortnoise.flac file1.flac
977cp shortnoise.flac file2.flac
978rm -f shortnoise.flac
979cp shortnoise.wav file0.wav
980cp shortnoise.wav file1.wav
981cp shortnoise.wav file2.wav
982rm -f shortnoise.wav
983cp shortnoise.aiff file0.aiff
984cp shortnoise.aiff file1.aiff
985cp shortnoise.aiff file2.aiff
986rm -f shortnoise.aiff
987cp shortnoise.raw file0.raw
988cp shortnoise.raw file1.raw
989cp shortnoise.raw file2.raw
990rm -f shortnoise.raw
Josh Coalsonc2751e62005-08-27 01:57:39 +0000991# create authoritative sector-aligned files for comparison
Josh Coalsonbfda3782006-08-28 03:42:10 +0000992file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
993file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
994file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
995file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
Josh Coalsonc2751e62005-08-27 01:57:39 +0000996file1_samples=`expr $file1_samples - $file0_remainder`
Josh Coalsonbfda3782006-08-28 03:42:10 +0000997file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
998file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
Josh Coalsonc2751e62005-08-27 01:57:39 +0000999file2_samples=`expr $file2_samples - $file1_remainder`
1000if [ $file2_remainder != '0' ] ; then
1001 file2_samples=`expr $file2_samples + $file2_remainder`
1002 file2_remainder=`expr 588 - $file2_remainder`
1003fi
1004
1005dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
1006dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
1007dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
1008cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
1009dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
1010dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
1011cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
1012dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
1013cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
1014rm -f z.raw
1015
Josh Coalsonbfda3782006-08-28 03:42:10 +00001016convert_to_wav file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
1017convert_to_wav file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
1018convert_to_wav file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
Josh Coalsonc2751e62005-08-27 01:57:39 +00001019
Josh Coalsonbfda3782006-08-28 03:42:10 +00001020convert_to_aiff file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
1021convert_to_aiff file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
1022convert_to_aiff file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
Josh Coalson463d0f82002-12-10 06:41:27 +00001023
1024test_multifile ()
1025{
Josh Coalsonc2751e62005-08-27 01:57:39 +00001026 input_type=$1
1027 streamtype=$2
1028 sector_align=$3
1029 encode_options="$4"
1030
1031 extra_encode_options=""
1032 extra_decode_options=""
1033 if [ $input_type = "raw" ] ; then
1034 extra_encode_options="--force-raw-format $multifile_format_encode"
1035 extra_decode_options="--force-raw-format $multifile_format_decode"
1036 else
1037 if [ $input_type = "aiff" ] ; then
1038 extra_decode_options="--force-aiff-format"
1039 fi
1040 fi
Josh Coalson463d0f82002-12-10 06:41:27 +00001041
1042 if [ $streamtype = ogg ] ; then
1043 suffix=ogg
1044 encode_options="$encode_options --ogg"
1045 else
1046 suffix=flac
1047 fi
1048
1049 if [ $sector_align = sector_align ] ; then
1050 encode_options="$encode_options --sector-align"
1051 fi
1052
Josh Coalsonc28efe22006-11-04 03:04:21 +00001053 if [ $input_type = flac ] || [ $input_type = ogg ] ; then
Josh Coalsonbfda3782006-08-28 03:42:10 +00001054 CMP=md5cmp
1055 else
1056 CMP=cmp
1057 fi
1058
Josh Coalson463d0f82002-12-10 06:41:27 +00001059 for n in 0 1 2 ; do
Josh Coalsonbfda3782006-08-28 03:42:10 +00001060 cp file$n.$input_type file${n}x.$input_type
Josh Coalson463d0f82002-12-10 06:41:27 +00001061 done
Josh Coalsonbfda3782006-08-28 03:42:10 +00001062 run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
Josh Coalsonc2751e62005-08-27 01:57:39 +00001063 run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
Josh Coalson463d0f82002-12-10 06:41:27 +00001064 if [ $sector_align != sector_align ] ; then
1065 for n in 0 1 2 ; do
Josh Coalsonbfda3782006-08-28 03:42:10 +00001066 $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
Josh Coalsonc2751e62005-08-27 01:57:39 +00001067 done
1068 else
1069 for n in 0 1 2 ; do
Josh Coalsonbfda3782006-08-28 03:42:10 +00001070 $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
Josh Coalson463d0f82002-12-10 06:41:27 +00001071 done
1072 fi
1073 for n in 0 1 2 ; do
Josh Coalsonc2751e62005-08-27 01:57:39 +00001074 rm -f file${n}x.$suffix file${n}x.$input_type
Josh Coalson463d0f82002-12-10 06:41:27 +00001075 done
1076}
1077
Josh Coalsonc28efe22006-11-04 03:04:21 +00001078input_types="raw wav aiff flac"
1079#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
1080#@@@if [ $has_ogg = yes ] ; then
1081#@@@ input_types="$input_types ogg"
1082#@@@fi
1083for input_type in $input_types ; do
Josh Coalsonc2751e62005-08-27 01:57:39 +00001084 echo "Testing multiple $input_type files without verify..."
1085 test_multifile $input_type flac no_sector_align ""
Josh Coalson463d0f82002-12-10 06:41:27 +00001086
Josh Coalsonc2751e62005-08-27 01:57:39 +00001087 echo "Testing multiple $input_type files with verify..."
1088 test_multifile $input_type flac no_sector_align "--verify"
Josh Coalson463d0f82002-12-10 06:41:27 +00001089
Josh Coalsonc28efe22006-11-04 03:04:21 +00001090 if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
Josh Coalsonbfda3782006-08-28 03:42:10 +00001091 echo "Testing multiple $input_type files with --sector-align, without verify..."
1092 test_multifile $input_type flac sector_align ""
Josh Coalson463d0f82002-12-10 06:41:27 +00001093
Josh Coalsonbfda3782006-08-28 03:42:10 +00001094 echo "Testing multiple $input_type files with --sector-align, with verify..."
1095 test_multifile $input_type flac sector_align "--verify"
1096 fi
Josh Coalson463d0f82002-12-10 06:41:27 +00001097
Josh Coalsonc28efe22006-11-04 03:04:21 +00001098 if [ $has_ogg = yes ] ; then
Josh Coalsonc2751e62005-08-27 01:57:39 +00001099 echo "Testing multiple $input_type files with --ogg, without verify..."
1100 test_multifile $input_type ogg no_sector_align ""
Josh Coalson463d0f82002-12-10 06:41:27 +00001101
Josh Coalsonc2751e62005-08-27 01:57:39 +00001102 echo "Testing multiple $input_type files with --ogg, with verify..."
1103 test_multifile $input_type ogg no_sector_align "--verify"
Josh Coalson463d0f82002-12-10 06:41:27 +00001104
Josh Coalsonbfda3782006-08-28 03:42:10 +00001105 if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
1106 echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
1107 test_multifile $input_type ogg sector_align ""
Josh Coalson463d0f82002-12-10 06:41:27 +00001108
Josh Coalsonbfda3782006-08-28 03:42:10 +00001109 echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
1110 test_multifile $input_type ogg sector_align "--verify"
1111 fi
Josh Coalson463d0f82002-12-10 06:41:27 +00001112
Josh Coalsonc2751e62005-08-27 01:57:39 +00001113 echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
1114 test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
1115 fi
1116done
Josh Coalsonbfda3782006-08-28 03:42:10 +00001117
1118
1119############################################################################
1120# test the metadata-handling properties of flac-to-flac encoding
1121############################################################################
1122
1123echo "Testing the metadata-handling properties of flac-to-flac encoding..."
1124
1125testdir="flac-to-flac-metadata-test-files"
1126filter ()
1127{
Josh Coalsona5023532007-02-04 04:28:37 +00001128 # minor danger, changing vendor strings might change the length of the
Josh Coalsonbfda3782006-08-28 03:42:10 +00001129 # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
1130 # we lose info about PADDING size that we need
1131 grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
1132}
1133flac2flac ()
1134{
1135 file="$1"
1136 case="$2"
1137 args="$3"
1138 expect="$case-expect.meta"
1139 echo -n "$case... "
1140 run_flac $SILENT -f -o out.flac $args $file || die "ERROR encoding FLAC file"
1141 run_metaflac --list out.flac | filter > out.meta || die "ERROR listing metadata of output FLAC file"
1142 diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
1143 echo OK
1144}
1145
1146#filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
1147cd $testdir || die "ERROR changing to directory $testdir"
1148
1149# case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
1150flac2flac input-SCVAUP.flac case00a ""
1151# case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
1152flac2flac input-SCVPAP.flac case01a ""
1153# case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
1154flac2flac input-SCVPAP.flac case01b "--no-padding"
1155# case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
1156flac2flac input-SCVPAP.flac case01c "-P 1234"
1157# case 01d: on file with no PADDING blocks, use -P setting
1158flac2flac input-SCVA.flac case01d "-P 1234"
1159# case 01e: on file with no PADDING blocks and no -P given, use default padding
1160flac2flac input-SCVA.flac case01e ""
1161# case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
1162flac2flac input-SCPAP.flac case02a ""
1163# case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
1164flac2flac input-SCPAP.flac case02b "--tag=artist=0"
1165# case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
1166flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
1167# case 03a: on file with no CUESHEET block and --cuesheet specified, add it
1168flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
1169# case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
1170flac2flac input-SCVAUP.flac case03b "$TOTALLY_SILENT --cuesheet=input0.cue"
1171# case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
1172flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
1173# case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
1174flac2flac input-VA.flac case04a "--no-padding --no-seektable"
1175# case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
1176flac2flac input-VA.flac case04b "--no-padding -S 5x"
1177# case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
1178flac2flac input-VA.flac case04c "--no-padding"
1179# case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
1180flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
1181# case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
1182flac2flac input-SCVA.flac case04e "$TOTALLY_SILENT --no-padding -S 5x"
1183# case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
1184#(already covered by case03c)
1185
1186rm -f out.flac out.meta
1187
Josh Coalsonc28efe22006-11-04 03:04:21 +00001188#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
1189
Josh Coalsonbfda3782006-08-28 03:42:10 +00001190cd ..