~ubuntu-branches/ubuntu/precise/flac/precise-updates

« back to all changes in this revision

Viewing changes to test/test_flac.sh

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-05-29 22:56:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529225636-ljeff8xxip09qaap
Tags: 1.1.4-1
* New upstream release. closes: #405167, #411311
  - libOggFLAC and libOggFLAC++ have been merged into libFLAC, so
    remove their corresponding packages.
  - Because of the API changes required to effect the above, there has
    been yet another soname bump. libflac7 -> libflac8 and
    libflac++5 -> libflac++6. Emails have been dispatched to the
    maintainers of dependent packages.
* Some notes on patches that were removed:
  - 02_stdin_stdout, 06_manpage_mention_utf8_convert: merged upstream
  - 08_manpage_warnings: Upstream has changed the manpage so it defintely
    can't fit in in 80 cols, so just forget about it. We'll live.
  - 05_eof_warnings_are_errors: Upstream decided to add a -w option to
    flac to treat all warnings as errors. I am going to defer to that
    for now, but if people think it's stupid let me know and I'll port
    the patch forward.
  - 04_stack_smasher: was a backport from 1.1.3, so it's obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
 
3
3
#  FLAC - Free Lossless Audio Codec
4
 
#  Copyright (C) 2001,2002,2003,2004,2005  Josh Coalson
 
4
#  Copyright (C) 2001,2002,2003,2004,2005,2006,2007  Josh Coalson
5
5
#
6
6
#  This file is part the FLAC project.  FLAC is comprised of several
7
7
#  components distributed under difference licenses.  The codec libraries
23
23
        exit 1
24
24
}
25
25
 
26
 
if [ x = x"$1" ] ; then 
 
26
dddie="die ERROR: creating files with dd"
 
27
 
 
28
if [ x = x"$1" ] ; then
27
29
        BUILD=debug
28
30
else
29
31
        BUILD="$1"
30
32
fi
31
33
 
32
 
LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
33
 
LD_LIBRARY_PATH=../src/libOggFLAC/.libs:$LD_LIBRARY_PATH
34
 
LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
35
 
LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
36
 
LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
37
 
LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
38
 
LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
39
 
LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
 
34
# change to 'false' to show flac output (useful for debugging)
 
35
if true ; then
 
36
        SILENT='--silent'
 
37
        TOTALLY_SILENT='--totally-silent'
 
38
else
 
39
        SILENT=''
 
40
        TOTALLY_SILENT=''
 
41
fi
 
42
 
 
43
LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
 
44
LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
 
45
LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
 
46
LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
 
47
LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
 
48
LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
 
49
LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
40
50
export LD_LIBRARY_PATH
41
 
PATH=../src/flac:$PATH
42
 
PATH=../src/metaflac:$PATH
43
 
PATH=../src/test_streams:$PATH
44
 
PATH=../obj/$BUILD/bin:$PATH
 
51
PATH=`pwd`/../src/flac:$PATH
 
52
PATH=`pwd`/../src/metaflac:$PATH
 
53
PATH=`pwd`/../src/test_streams:$PATH
 
54
PATH=`pwd`/../obj/$BUILD/bin:$PATH
45
55
 
46
56
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
47
57
 
48
58
run_flac ()
49
59
{
50
 
        if [ x"$FLAC__VALGRIND" = xyes ] ; then
 
60
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
 
61
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_flac.valgrind.log
51
62
                valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
52
63
        else
53
64
                flac $*
56
67
 
57
68
run_metaflac ()
58
69
{
59
 
        if [ x"$FLAC__VALGRIND" = xyes ] ; then
 
70
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
 
71
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 metaflac $*" >>test_flac.valgrind.log
60
72
                valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_flac.valgrind.log
61
73
        else
62
74
                metaflac $*
63
75
        fi
64
76
}
65
77
 
 
78
md5cmp ()
 
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
 
66
85
if [ `env | grep -ic '^comspec='` != 0 ] ; then
67
86
        is_win=yes
68
87
else
70
89
fi
71
90
 
72
91
echo "Checking for --ogg support in flac..."
73
 
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
 
92
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
74
93
        has_ogg=yes;
75
94
        echo "flac --ogg works"
76
95
else
78
97
        echo "flac --ogg doesn't work"
79
98
fi
80
99
 
81
 
 
82
100
echo "Generating streams..."
83
101
if [ ! -f wacky1.wav ] ; then
84
102
        test_streams || die "ERROR during test_streams"
91
109
echo "Try encoding to a file that exists; should fail"
92
110
cp wacky1.wav exist.wav
93
111
touch exist.flac
94
 
if run_flac --totally-silent -0 exist.wav ; then
 
112
if run_flac $TOTALLY_SILENT -0 exist.wav ; then
95
113
        die "ERROR: it should have failed but didn't"
96
114
else
97
115
        echo "OK, it failed as it should"
98
116
fi
99
117
 
100
118
echo "Try encoding with -f to a file that exists; should succeed"
101
 
if run_flac --totally-silent -0 --force exist.wav ; then
 
119
if run_flac $TOTALLY_SILENT -0 --force exist.wav ; then
102
120
        echo "OK, it succeeded as it should"
103
121
else
104
122
        die "ERROR: it should have succeeded but didn't"
105
123
fi
106
124
 
107
125
echo "Try decoding to a file that exists; should fail"
108
 
if run_flac --totally-silent -d exist.flac ; then
 
126
if run_flac $TOTALLY_SILENT -d exist.flac ; then
109
127
        die "ERROR: it should have failed but didn't"
110
128
else
111
129
        echo "OK, it failed as it should"
112
130
fi
113
131
 
114
132
echo "Try decoding with -f to a file that exists; should succeed"
115
 
if run_flac --totally-silent -d -f exist.flac ; then
 
133
if run_flac $TOTALLY_SILENT -d -f exist.flac ; then
116
134
        echo "OK, it succeeded as it should"
117
135
else
118
136
        die "ERROR: it should have succeeded but didn't"
121
139
rm -f exist.wav exist.flac
122
140
 
123
141
############################################################################
 
142
# test fractional block sizes
 
143
############################################################################
 
144
 
 
145
test_fractional ()
 
146
{
 
147
        blocksize=$1
 
148
        samples=$2
 
149
        dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie
 
150
        echo -n "fractional block size test (blocksize=$blocksize samples=$samples) encode... "
 
151
        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"
 
152
        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
 
158
}
 
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.
 
166
for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do
 
167
        test_fractional 33 $samples
 
168
done
 
169
for 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
 
171
done
 
172
for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
 
173
        test_fractional 2048 $samples
 
174
done
 
175
for 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
 
177
done
 
178
 
 
179
############################################################################
124
180
# basic 'round-trip' tests of various kinds of streams
125
181
############################################################################
126
182
 
128
184
{
129
185
        f="$1"
130
186
        channels=`echo $f | awk -F- '{print $2}'`
131
 
        bytes_per_sample=`echo $f | awk -F- '{print $3}'`
132
 
        bps=`expr $bytes_per_sample '*' 8`
 
187
        bps=`echo $f | awk -F- '{print $3}'`
133
188
        echo -n "round-trip test ($f) encode... "
134
 
        run_flac --silent --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $f -o rt.flac || die "ERROR"
 
189
        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"
135
190
        echo -n "decode... "
136
 
        run_flac --silent --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
 
191
        run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
137
192
        echo -n "compare... "
138
193
        cmp $f rt.raw || die "ERROR: file mismatch"
139
194
        echo "OK"
144
199
{
145
200
        f="$1"
146
201
        echo -n "round-trip test ($f) encode... "
147
 
        run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
 
202
        run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
148
203
        echo -n "decode... "
149
 
        run_flac --silent --force --decode -o rt.wav rt.flac || die "ERROR"
 
204
        run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt.flac || die "ERROR"
150
205
        echo -n "compare... "
151
206
        cmp $f rt.wav || die "ERROR: file mismatch"
152
207
        echo "OK"
157
212
{
158
213
        f="$1"
159
214
        echo -n "round-trip test ($f) encode... "
160
 
        run_flac --silent --force --verify $f -o rt.flac || die "ERROR"
 
215
        run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
161
216
        echo -n "decode... "
162
 
        run_flac --silent --force --decode -o rt.aiff rt.flac || die "ERROR"
 
217
        run_flac $SILENT --force --decode --channel-map=none -o rt.aiff rt.flac || die "ERROR"
163
218
        echo -n "compare... "
164
219
        cmp $f rt.aiff || die "ERROR: file mismatch"
165
220
        echo "OK"
166
221
        rm -f rt.flac rt.aiff
167
222
}
168
223
 
 
224
# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
 
225
rt_test_flac ()
 
226
{
 
227
        f="$1"
 
228
        echo -n "round-trip test ($f->flac->flac->wav) encode... "
 
229
        run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
 
230
        echo -n "re-encode... "
 
231
        run_flac $SILENT --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
 
232
        echo -n "decode... "
 
233
        run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.flac || die "ERROR"
 
234
        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
 
 
240
# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
 
241
rt_test_ogg_flac ()
 
242
{
 
243
        f="$1"
 
244
        echo -n "round-trip test ($f->oggflac->oggflac->wav) encode... "
 
245
        run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.ogg --ogg $f || die "ERROR"
 
246
        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
 
169
256
for f in rt-*.raw ; do
170
257
        rt_test_raw $f
171
258
done
175
262
for f in rt-*.aiff ; do
176
263
        rt_test_aiff $f
177
264
done
 
265
for f in rt-*.wav ; do
 
266
        rt_test_flac $f
 
267
done
 
268
if [ $has_ogg = yes ] ; then
 
269
        for f in rt-*.wav ; do
 
270
                rt_test_ogg_flac $f
 
271
        done
 
272
fi
178
273
 
179
274
############################################################################
180
275
# test --skip and --until
184
279
# first make some chopped-up raw files
185
280
#
186
281
echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
187
 
dddie="die ERROR: creating files for --skip/--until tests"
188
282
dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
189
283
dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
190
284
dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
202
296
dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
203
297
dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
204
298
 
205
 
wav_eopt="--silent --force --verify --lax"
206
 
wav_dopt="--silent --force --decode"
 
299
wav_eopt="$SILENT --force --verify --no-padding --lax"
 
300
wav_dopt="$SILENT --force --decode"
207
301
 
208
302
raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
209
303
raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
210
304
 
211
305
#
212
 
# convert them to WAVE and AIFF files
 
306
# convert them to WAVE/AIFF/Ogg FLAC files
213
307
#
214
308
convert_to_wav ()
215
309
{
216
 
        run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to WAVE"
217
 
        run_flac $wav_dopt $1.flac || die "ERROR converting $1.raw to WAVE"
 
310
        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"
218
312
}
219
 
convert_to_wav 50c
220
 
convert_to_wav 50c.skip10
221
 
convert_to_wav 50c.skip11
222
 
convert_to_wav 50c.skip20
223
 
convert_to_wav 50c.skip30
224
 
convert_to_wav 50c.skip40
225
 
convert_to_wav 50c.until10
226
 
convert_to_wav 50c.until20
227
 
convert_to_wav 50c.until30
228
 
convert_to_wav 50c.until39
229
 
convert_to_wav 50c.until40
230
 
convert_to_wav 50c.skip10.until30
231
 
convert_to_wav 50c.skip10.until39
232
 
convert_to_wav 50c.skip10.until40
233
 
convert_to_wav 50c.skip20.until30
234
 
convert_to_wav 50c.skip20.until40
 
313
convert_to_wav 50c "$raw_eopt" "$wav_dopt"
 
314
convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
 
315
convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
 
316
convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
 
317
convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
 
318
convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
 
319
convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
 
320
convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
 
321
convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
 
322
convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
 
323
convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
 
324
convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
 
325
convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
 
326
convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
 
327
convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
 
328
convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
235
329
 
236
330
convert_to_aiff ()
237
331
{
238
 
        run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to AIFF"
239
 
        run_flac $wav_dopt $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
240
 
}
241
 
convert_to_aiff 50c
242
 
convert_to_aiff 50c.skip10
243
 
convert_to_aiff 50c.skip11
244
 
convert_to_aiff 50c.skip20
245
 
convert_to_aiff 50c.skip30
246
 
convert_to_aiff 50c.skip40
247
 
convert_to_aiff 50c.until10
248
 
convert_to_aiff 50c.until20
249
 
convert_to_aiff 50c.until30
250
 
convert_to_aiff 50c.until39
251
 
convert_to_aiff 50c.until40
252
 
convert_to_aiff 50c.skip10.until30
253
 
convert_to_aiff 50c.skip10.until39
254
 
convert_to_aiff 50c.skip10.until40
255
 
convert_to_aiff 50c.skip20.until30
256
 
convert_to_aiff 50c.skip20.until40
 
332
        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"
 
334
}
 
335
convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
 
336
convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
 
337
convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
 
338
convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
 
339
convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
 
340
convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
 
341
convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
 
342
convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
 
343
convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
 
344
convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
 
345
convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
 
346
convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
 
347
convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
 
348
convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
 
349
convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
 
350
convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
 
351
 
 
352
convert_to_ogg ()
 
353
{
 
354
        run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
 
355
}
 
356
if [ $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
 
373
fi
257
374
 
258
375
test_skip_until ()
259
376
{
260
377
        in_fmt=$1
261
378
        out_fmt=$2
262
379
 
263
 
        [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
 
380
        [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
264
381
 
265
382
        [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
266
383
 
272
389
                dopt="$wav_dopt"
273
390
        fi
274
391
 
 
392
        if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
 
393
                CMP=md5cmp
 
394
        else
 
395
                CMP=cmp
 
396
        fi
 
397
 
275
398
        if [ $out_fmt = ogg ] ; then
276
399
                eopt="--ogg $eopt"
277
400
        fi
284
407
 
285
408
        echo -n "testing --skip=# (encode) $desc... "
286
409
        run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
287
 
        run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
288
 
        cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
 
410
        [ $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"
289
412
        rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
290
413
        echo OK
291
414
 
292
415
        echo -n "testing --skip=mm:ss (encode) $desc... "
293
416
        run_flac $eopt --skip=0:01 -o z50c.skip0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
294
 
        run_flac $dopt -o z50c.skip0:01.$in_fmt z50c.skip0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
295
 
        cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
 
417
        [ $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"
296
419
        rm -f z50c.skip0:01.$out_fmt z50c.skip0:01.$in_fmt
297
420
        echo OK
298
421
 
299
422
        echo -n "testing --skip=mm:ss.sss (encode) $desc... "
300
423
        run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
301
 
        run_flac $dopt -o z50c.skip0:01.1001.$in_fmt z50c.skip0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
302
 
        cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
 
424
        [ $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"
303
426
        rm -f z50c.skip0:01.1001.$out_fmt z50c.skip0:01.1001.$in_fmt
304
427
        echo OK
305
428
 
307
430
        # test --skip when decoding
308
431
        #
309
432
 
 
433
        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
 
310
435
        echo -n "testing --skip=# (decode) $desc... "
311
 
        run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
312
436
        run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
313
 
        cmp 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
 
437
        $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
314
438
        rm -f z50c.skip10.$in_fmt
315
439
        echo OK
316
440
 
317
441
        echo -n "testing --skip=mm:ss (decode) $desc... "
318
442
        run_flac $dopt --skip=0:01 -o z50c.skip0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
319
 
        cmp 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
 
443
        $CMP 50c.skip10.$in_fmt z50c.skip0:01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
320
444
        rm -f z50c.skip0:01.$in_fmt
321
445
        echo OK
322
446
 
323
447
        echo -n "testing --skip=mm:ss.sss (decode) $desc... "
324
448
        run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
325
 
        cmp 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
 
449
        $CMP 50c.skip11.$in_fmt z50c.skip0:01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
326
450
        rm -f z50c.skip0:01.1001.$in_fmt
327
451
        echo OK
328
452
 
334
458
 
335
459
        echo -n "testing --until=# (encode) $desc... "
336
460
        run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
337
 
        run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
338
 
        cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
 
461
        [ $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"
339
463
        rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
340
464
        echo OK
341
465
 
342
466
        echo -n "testing --until=mm:ss (encode) $desc... "
343
467
        run_flac $eopt --until=0:04 -o z50c.until0:04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
344
 
        run_flac $dopt -o z50c.until0:04.$in_fmt z50c.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
345
 
        cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
 
468
        [ $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"
346
470
        rm -f z50c.until0:04.$out_fmt z50c.until0:04.$in_fmt
347
471
        echo OK
348
472
 
349
473
        echo -n "testing --until=mm:ss.sss (encode) $desc... "
350
474
        run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
351
 
        run_flac $dopt -o z50c.until0:03.9001.$in_fmt z50c.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
352
 
        cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
 
475
        [ $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"
353
477
        rm -f z50c.until0:03.9001.$out_fmt z50c.until0:03.9001.$in_fmt
354
478
        echo OK
355
479
 
356
480
        echo -n "testing --until=-# (encode) $desc... "
357
481
        run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
358
 
        run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
359
 
        cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
 
482
        [ $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"
360
484
        rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
361
485
        echo OK
362
486
 
363
487
        echo -n "testing --until=-mm:ss (encode) $desc... "
364
488
        run_flac $eopt --until=-0:01 -o z50c.until-0:01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
365
 
        run_flac $dopt -o z50c.until-0:01.$in_fmt z50c.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
366
 
        cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
 
489
        [ $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"
367
491
        rm -f z50c.until-0:01.$out_fmt z50c.until-0:01.$in_fmt
368
492
        echo OK
369
493
 
370
494
        echo -n "testing --until=-mm:ss.sss (encode) $desc... "
371
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"
372
 
        run_flac $dopt -o z50c.until-0:01.1001.$in_fmt z50c.until-0:01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
373
 
        cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
 
496
        [ $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"
374
498
        rm -f z50c.until-0:01.1001.$out_fmt z50c.until-0:01.1001.$in_fmt
375
499
        echo OK
376
500
 
378
502
        # test --until when decoding
379
503
        #
380
504
 
381
 
        run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
 
505
        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"
382
506
 
383
507
        echo -n "testing --until=# (decode) $desc... "
384
508
        run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
385
 
        cmp 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
 
509
        $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
386
510
        rm -f z50c.until40.$in_fmt
387
511
        echo OK
388
512
 
389
513
        echo -n "testing --until=mm:ss (decode) $desc... "
390
514
        run_flac $dopt --until=0:04 -o z50c.until0:04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
391
 
        cmp 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
 
515
        $CMP 50c.until40.$in_fmt z50c.until0:04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
392
516
        rm -f z50c.until0:04.$in_fmt
393
517
        echo OK
394
518
 
395
519
        echo -n "testing --until=mm:ss.sss (decode) $desc... "
396
520
        run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
397
 
        cmp 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
 
521
        $CMP 50c.until39.$in_fmt z50c.until0:03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
398
522
        rm -f z50c.until0:03.9001.$in_fmt
399
523
        echo OK
400
524
 
401
525
        echo -n "testing --until=-# (decode) $desc... "
402
526
        run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
403
 
        cmp 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
 
527
        $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
404
528
        rm -f z50c.until-10.$in_fmt
405
529
        echo OK
406
530
 
407
531
        echo -n "testing --until=-mm:ss (decode) $desc... "
408
532
        run_flac $dopt --until=-0:01 -o z50c.until-0:01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
409
 
        cmp 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
 
533
        $CMP 50c.until40.$in_fmt z50c.until-0:01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
410
534
        rm -f z50c.until-0:01.$in_fmt
411
535
        echo OK
412
536
 
413
537
        echo -n "testing --until=-mm:ss.sss (decode) $desc... "
414
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"
415
 
        cmp 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
 
539
        $CMP 50c.until39.$in_fmt z50c.until-0:01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
416
540
        rm -f z50c.until-0:01.1001.$in_fmt
417
541
        echo OK
418
542
 
424
548
 
425
549
        echo -n "testing --skip=10 --until=# (encode) $desc... "
426
550
        run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
427
 
        run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
428
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
 
551
        [ $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"
429
553
        rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
430
554
        echo OK
431
555
 
432
556
        echo -n "testing --skip=10 --until=mm:ss (encode) $desc... "
433
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"
434
 
        run_flac $dopt -o z50c.skip10.until0:04.$in_fmt z50c.skip10.until0:04.$out_fmt || die "ERROR decoding FLAC file $desc"
435
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
 
558
        [ $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"
436
560
        rm -f z50c.skip10.until0:04.$out_fmt z50c.skip10.until0:04.$in_fmt
437
561
        echo OK
438
562
 
439
563
        echo -n "testing --skip=10 --until=mm:ss.sss (encode) $desc... "
440
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"
441
 
        run_flac $dopt -o z50c.skip10.until0:03.9001.$in_fmt z50c.skip10.until0:03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
442
 
        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"
 
565
        [ $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"
443
567
        rm -f z50c.skip10.until0:03.9001.$out_fmt z50c.skip10.until0:03.9001.$in_fmt
444
568
        echo OK
445
569
 
446
570
        echo -n "testing --skip=10 --until=+# (encode) $desc... "
447
571
        run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
448
 
        run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
449
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
 
572
        [ $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"
450
574
        rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
451
575
        echo OK
452
576
 
453
577
        echo -n "testing --skip=10 --until=+mm:ss (encode) $desc... "
454
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"
455
 
        run_flac $dopt -o z50c.skip10.until+0:03.$in_fmt z50c.skip10.until+0:03.$out_fmt || die "ERROR decoding FLAC file $desc"
456
 
        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"
 
579
        [ $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"
457
581
        rm -f z50c.skip10.until+0:03.$out_fmt z50c.skip10.until+0:03.$in_fmt
458
582
        echo OK
459
583
 
460
584
        echo -n "testing --skip=10 --until=+mm:ss.sss (encode) $desc... "
461
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"
462
 
        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"
463
 
        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"
 
586
        [ $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"
464
588
        rm -f z50c.skip10.until+0:02.9001.$out_fmt z50c.skip10.until+0:02.9001.$in_fmt
465
589
        echo OK
466
590
 
467
591
        echo -n "testing --skip=10 --until=-# (encode) $desc... "
468
592
        run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
469
 
        run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
470
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
 
593
        [ $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"
471
595
        rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
472
596
        echo OK
473
597
 
474
598
        echo -n "testing --skip=10 --until=-mm:ss (encode) $desc... "
475
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"
476
 
        run_flac $dopt -o z50c.skip10.until-0:01.$in_fmt z50c.skip10.until-0:01.$out_fmt || die "ERROR decoding FLAC file $desc"
477
 
        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"
 
600
        [ $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"
478
602
        rm -f z50c.skip10.until-0:01.$out_fmt z50c.skip10.until-0:01.$in_fmt
479
603
        echo OK
480
604
 
481
605
        echo -n "testing --skip=10 --until=-mm:ss.sss (encode) $desc... "
482
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"
483
 
        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"
484
 
        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"
 
607
        [ $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"
485
609
        rm -f z50c.skip10.until-0:01.1001.$out_fmt z50c.skip10.until-0:01.1001.$in_fmt
486
610
        echo OK
487
611
 
489
613
        # test --skip and --until when decoding
490
614
        #
491
615
 
492
 
        run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
 
616
        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
 
493
618
 
494
619
        echo -n "testing --skip=10 --until=# (decode) $desc... "
495
620
        run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
496
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
 
621
        $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
497
622
        rm -f z50c.skip10.until40.$in_fmt
498
623
        echo OK
499
624
 
500
625
        echo -n "testing --skip=10 --until=mm:ss (decode) $desc... "
501
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"
502
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
 
627
        $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0:04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
503
628
        rm -f z50c.skip10.until0:04.$in_fmt
504
629
        echo OK
505
630
 
506
631
        echo -n "testing --skip=10 --until=mm:ss.sss (decode) $desc... "
507
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"
508
 
        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"
 
633
        $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"
509
634
        rm -f z50c.skip10.until0:03.9001.$in_fmt
510
635
        echo OK
511
636
 
512
637
        echo -n "testing --skip=10 --until=-# (decode) $desc... "
513
638
        run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
514
 
        cmp 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
 
639
        $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
515
640
        rm -f z50c.skip10.until-10.$in_fmt
516
641
        echo OK
517
642
 
518
643
        echo -n "testing --skip=10 --until=-mm:ss (decode) $desc... "
519
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"
520
 
        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"
 
645
        $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"
521
646
        rm -f z50c.skip10.until-0:01.$in_fmt
522
647
        echo OK
523
648
 
524
649
        echo -n "testing --skip=10 --until=-mm:ss.sss (decode) $desc... "
525
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"
526
 
        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"
 
651
        $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"
527
652
        rm -f z50c.skip10.until-0:01.1001.$in_fmt
528
653
        echo OK
529
654
 
533
658
test_skip_until raw flac
534
659
test_skip_until wav flac
535
660
test_skip_until aiff flac
 
661
test_skip_until flac flac
 
662
#@@@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
536
666
 
537
 
if [ $has_ogg = "yes" ] ; then
 
667
if [ $has_ogg = yes ] ; then
538
668
        test_skip_until raw ogg
539
669
        test_skip_until wav ogg
540
670
        test_skip_until aiff ogg
 
671
        #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
 
672
        #@@@test_skip_until flac ogg
 
673
        #@@@test_skip_until ogg ogg
541
674
fi
542
675
 
543
676
echo "testing seek extremes:"
544
677
 
545
 
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"
 
678
run_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"
546
679
 
547
680
if [ $is_win = no ] ; then
548
 
        total_samples=`run_metaflac --show-total-samples noise.flac`
 
681
        total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
549
682
        [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
550
683
else
551
684
        # some flavors of cygwin don't seem to treat the \x0d as a word
552
685
        # separator, so we hard code it.  we'll just have to fix it later
553
686
        # if we change the way noise.flac is made.
554
 
        total_samples=393216
 
687
        total_noise_cdda_samples=393216
555
688
fi
556
689
 
557
690
echo -n "testing --skip=0... "
559
692
echo OK
560
693
 
561
694
for delta in 2 1 ; do
562
 
        n=`expr $total_samples - $delta`
 
695
        n=`expr $total_noise_cdda_samples - $delta`
563
696
        echo -n "testing --skip=$n... "
564
697
        run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
565
698
        echo OK
572
705
# test --input-size
573
706
############################################################################
574
707
 
575
 
#@@@@@@ cat will not work on old cygwin, need to fix
 
708
#@@@ cat will not work on old cygwin, need to fix
576
709
if [ $is_win = no ] ; then
577
710
        echo -n "testing --input-size=50 --skip=10... "
578
711
        cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
584
717
 
585
718
 
586
719
############################################################################
587
 
# test --skip and --until
588
 
############################################################################
589
 
 
590
 
############################################################################
591
720
# test --cue
592
721
############################################################################
593
722
 
613
742
        in_fmt=$1
614
743
        out_fmt=$2
615
744
 
616
 
        [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
 
745
        [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
617
746
 
618
747
        [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
619
748
 
625
754
                dopt="$wav_dopt"
626
755
        fi
627
756
 
 
757
        if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
 
758
                CMP=md5cmp
 
759
        else
 
760
                CMP=cmp
 
761
        fi
 
762
 
628
763
        if [ $out_fmt = ogg ] ; then
629
764
                eopt="--ogg $eopt"
630
765
        fi
646
781
        # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
647
782
        #
648
783
        echo -n "testing --cue=- $desc... "
649
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
650
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
651
 
        rm -f z50c.cue.$in_fmt
 
784
        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
652
787
        echo OK
653
788
 
654
789
        echo -n "testing --cue=1.0 $desc... "
655
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
656
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
657
 
        rm -f z50c.cue.$in_fmt
 
790
        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
658
793
        echo OK
659
794
 
660
795
        echo -n "testing --cue=1.0- $desc... "
661
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
662
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
663
 
        rm -f z50c.cue.$in_fmt
 
796
        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
664
799
        echo OK
665
800
 
666
801
        echo -n "testing --cue=1.1 $desc... "
667
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
668
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
669
 
        rm -f z50c.cue.$in_fmt
 
802
        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
670
805
        echo OK
671
806
 
672
807
        echo -n "testing --cue=1.1- $desc... "
673
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
674
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
675
 
        rm -f z50c.cue.$in_fmt
 
808
        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
676
811
        echo OK
677
812
 
678
813
        echo -n "testing --cue=1.2 $desc... "
679
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
680
 
        cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
681
 
        rm -f z50c.cue.$in_fmt
 
814
        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
682
817
        echo OK
683
818
 
684
819
        echo -n "testing --cue=1.2- $desc... "
685
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
686
 
        cmp 50c.skip10.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
687
 
        rm -f z50c.cue.$in_fmt
 
820
        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
688
823
        echo OK
689
824
 
690
825
        echo -n "testing --cue=1.4 $desc... "
691
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
692
 
        cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
693
 
        rm -f z50c.cue.$in_fmt
 
826
        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
694
829
        echo OK
695
830
 
696
831
        echo -n "testing --cue=1.4- $desc... "
697
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
698
 
        cmp 50c.skip20.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
699
 
        rm -f z50c.cue.$in_fmt
 
832
        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
700
835
        echo OK
701
836
 
702
837
        echo -n "testing --cue=-5.0 $desc... "
703
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
704
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
705
 
        rm -f z50c.cue.$in_fmt
 
838
        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
706
841
        echo OK
707
842
 
708
843
        echo -n "testing --cue=-4.1 $desc... "
709
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
710
 
        cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
711
 
        rm -f z50c.cue.$in_fmt
 
844
        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
712
847
        echo OK
713
848
 
714
849
        echo -n "testing --cue=-3.1 $desc... "
715
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
716
 
        cmp 50c.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
717
 
        rm -f z50c.cue.$in_fmt
 
850
        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
718
853
        echo OK
719
854
 
720
855
        echo -n "testing --cue=-1.4 $desc... "
721
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
722
 
        cmp 50c.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
723
 
        rm -f z50c.cue.$in_fmt
 
856
        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
724
859
        echo OK
725
860
 
726
861
        echo -n "testing --cue=1.0-5.0 $desc... "
727
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
728
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
729
 
        rm -f z50c.cue.$in_fmt
 
862
        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
730
865
        echo OK
731
866
 
732
867
        echo -n "testing --cue=1.1-5.0 $desc... "
733
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
734
 
        cmp 50c.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
735
 
        rm -f z50c.cue.$in_fmt
 
868
        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
736
871
        echo OK
737
872
 
738
873
        echo -n "testing --cue=1.2-4.1 $desc... "
739
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
740
 
        cmp 50c.skip10.until40.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
741
 
        rm -f z50c.cue.$in_fmt
 
874
        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
742
877
        echo OK
743
878
 
744
879
        echo -n "testing --cue=1.4-2.0 $desc... "
745
 
        run_flac $dopt -o z50c.cue.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
746
 
        cmp 50c.skip20.until30.$in_fmt z50c.cue.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
747
 
        rm -f z50c.cue.$in_fmt
 
880
        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
748
883
        echo OK
749
884
 
750
885
        rm -f z50c.cue.$out_fmt
753
888
test_cue raw flac
754
889
test_cue wav flac
755
890
test_cue aiff flac
 
891
test_cue flac flac
 
892
#@@@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
756
896
 
757
 
if [ $has_ogg = "yes" ] ; then
 
897
if [ $has_ogg = yes ] ; then
758
898
        test_cue raw ogg
759
899
        test_cue wav ogg
760
900
        test_cue aiff ogg
 
901
        #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
 
902
        #@@@test_cue flac ogg
 
903
        #@@@test_cue ogg ogg
761
904
fi
762
905
 
763
906
############################################################################
769
912
echo -n "WAVE fixup test... "
770
913
 
771
914
echo -n "prepare... "
772
 
convert_to_wav noise || die "ERROR creating reference WAVE"
 
915
convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
773
916
 
774
917
echo -n "encode... "
775
918
# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
794
937
echo -n "AIFF fixup test... "
795
938
 
796
939
echo -n "prepare... "
797
 
convert_to_aiff noise || die "ERROR creating reference AIFF"
 
940
convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
798
941
 
799
942
echo -n "encode... "
800
943
# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
822
965
############################################################################
823
966
 
824
967
echo "Generating multiple input files from noise..."
825
 
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw || die "ERROR generating FLAC file"
826
 
run_flac --decode --force --silent noise.flac || die "ERROR generating WAVE file"
827
 
rm -f noise.flac
828
 
mv noise.wav file0.wav
829
 
cp file0.wav file1.wav
830
 
cp file1.wav file2.wav
 
968
multifile_format_decode="--endian=big --sign=signed"
 
969
multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding"
 
970
short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
 
971
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"
 
972
run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
 
973
run_flac --decode --force $SILENT shortnoise.flac || die "ERROR generating WAVE file"
 
974
run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
 
975
cp shortnoise.flac file0.flac
 
976
cp shortnoise.flac file1.flac
 
977
cp shortnoise.flac file2.flac
 
978
rm -f shortnoise.flac
 
979
cp shortnoise.wav file0.wav
 
980
cp shortnoise.wav file1.wav
 
981
cp shortnoise.wav file2.wav
 
982
rm -f shortnoise.wav
 
983
cp shortnoise.aiff file0.aiff
 
984
cp shortnoise.aiff file1.aiff
 
985
cp shortnoise.aiff file2.aiff
 
986
rm -f shortnoise.aiff
 
987
cp shortnoise.raw file0.raw
 
988
cp shortnoise.raw file1.raw
 
989
cp shortnoise.raw file2.raw
 
990
rm -f shortnoise.raw
 
991
# create authoritative sector-aligned files for comparison
 
992
file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
 
993
file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
 
994
file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
 
995
file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
 
996
file1_samples=`expr $file1_samples - $file0_remainder`
 
997
file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
 
998
file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
 
999
file2_samples=`expr $file2_samples - $file1_remainder`
 
1000
if [ $file2_remainder != '0' ] ; then
 
1001
        file2_samples=`expr $file2_samples + $file2_remainder`
 
1002
        file2_remainder=`expr 588 - $file2_remainder`
 
1003
fi
 
1004
 
 
1005
dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
 
1006
dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
 
1007
dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
 
1008
cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
 
1009
dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
 
1010
dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
 
1011
cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
 
1012
dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
 
1013
cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
 
1014
rm -f z.raw
 
1015
 
 
1016
convert_to_wav file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
 
1017
convert_to_wav file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
 
1018
convert_to_wav file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
 
1019
 
 
1020
convert_to_aiff file0s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
 
1021
convert_to_aiff file1s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
 
1022
convert_to_aiff file2s "$multifile_format_encode --force" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
831
1023
 
832
1024
test_multifile ()
833
1025
{
834
 
        streamtype=$1
835
 
        sector_align=$2
836
 
        encode_options="$3"
 
1026
        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
837
1041
 
838
1042
        if [ $streamtype = ogg ] ; then
839
1043
                suffix=ogg
846
1050
                encode_options="$encode_options --sector-align"
847
1051
        fi
848
1052
 
849
 
        run_flac --force $encode_options file0.wav file1.wav file2.wav || die "ERROR"
 
1053
        if [ $input_type = flac ] || [ $input_type = ogg ] ; then
 
1054
                CMP=md5cmp
 
1055
        else
 
1056
                CMP=cmp
 
1057
        fi
 
1058
 
850
1059
        for n in 0 1 2 ; do
851
 
                mv file$n.$suffix file${n}x.$suffix
 
1060
                cp file$n.$input_type file${n}x.$input_type
852
1061
        done
853
 
        run_flac --force --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
 
1062
        run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
 
1063
        run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
854
1064
        if [ $sector_align != sector_align ] ; then
855
1065
                for n in 0 1 2 ; do
856
 
                        cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
 
1066
                        $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
 
1067
                done
 
1068
        else
 
1069
                for n in 0 1 2 ; do
 
1070
                        $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
857
1071
                done
858
1072
        fi
859
1073
        for n in 0 1 2 ; do
860
 
                rm -f file${n}x.$suffix file${n}x.wav
 
1074
                rm -f file${n}x.$suffix file${n}x.$input_type
861
1075
        done
862
1076
}
863
1077
 
864
 
echo "Testing multiple files without verify..."
865
 
test_multifile flac no_sector_align ""
866
 
 
867
 
echo "Testing multiple files with verify..."
868
 
test_multifile flac no_sector_align "--verify"
869
 
 
870
 
echo "Testing multiple files with --sector-align, without verify..."
871
 
test_multifile flac sector_align ""
872
 
 
873
 
echo "Testing multiple files with --sector-align, with verify..."
874
 
test_multifile flac sector_align "--verify"
875
 
 
876
 
if [ $has_ogg = "yes" ] ; then
877
 
        echo "Testing multiple files with --ogg, without verify..."
878
 
        test_multifile ogg no_sector_align ""
879
 
 
880
 
        echo "Testing multiple files with --ogg, with verify..."
881
 
        test_multifile ogg no_sector_align "--verify"
882
 
 
883
 
        echo "Testing multiple files with --ogg and --sector-align, without verify..."
884
 
        test_multifile ogg sector_align ""
885
 
 
886
 
        echo "Testing multiple files with --ogg and --sector-align, with verify..."
887
 
        test_multifile sector_align ogg "--verify"
888
 
 
889
 
        echo "Testing multiple files with --ogg and --serial-number, with verify..."
890
 
        test_multifile ogg no_sector_align "--serial-number=321 --verify"
891
 
fi
 
1078
input_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
 
1083
for input_type in $input_types ; do
 
1084
        echo "Testing multiple $input_type files without verify..."
 
1085
        test_multifile $input_type flac no_sector_align ""
 
1086
 
 
1087
        echo "Testing multiple $input_type files with verify..."
 
1088
        test_multifile $input_type flac no_sector_align "--verify"
 
1089
 
 
1090
        if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
 
1091
                echo "Testing multiple $input_type files with --sector-align, without verify..."
 
1092
                test_multifile $input_type flac sector_align ""
 
1093
 
 
1094
                echo "Testing multiple $input_type files with --sector-align, with verify..."
 
1095
                test_multifile $input_type flac sector_align "--verify"
 
1096
        fi
 
1097
 
 
1098
        if [ $has_ogg = yes ] ; then
 
1099
                echo "Testing multiple $input_type files with --ogg, without verify..."
 
1100
                test_multifile $input_type ogg no_sector_align ""
 
1101
 
 
1102
                echo "Testing multiple $input_type files with --ogg, with verify..."
 
1103
                test_multifile $input_type ogg no_sector_align "--verify"
 
1104
 
 
1105
                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 ""
 
1108
 
 
1109
                        echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
 
1110
                        test_multifile $input_type ogg sector_align "--verify"
 
1111
                fi
 
1112
 
 
1113
                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
 
1116
done
 
1117
 
 
1118
 
 
1119
############################################################################
 
1120
# test the metadata-handling properties of flac-to-flac encoding
 
1121
############################################################################
 
1122
 
 
1123
echo "Testing the metadata-handling properties of flac-to-flac encoding..."
 
1124
 
 
1125
testdir="flac-to-flac-metadata-test-files"
 
1126
filter ()
 
1127
{
 
1128
        # minor danger, changing vendor strings might change the length of the
 
1129
        # 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
}
 
1133
flac2flac ()
 
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: '
 
1147
cd $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
 
1150
flac2flac input-SCVAUP.flac case00a ""
 
1151
# case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
 
1152
flac2flac input-SCVPAP.flac case01a ""
 
1153
# case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
 
1154
flac2flac 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
 
1156
flac2flac input-SCVPAP.flac case01c "-P 1234"
 
1157
# case 01d: on file with no PADDING blocks, use -P setting
 
1158
flac2flac input-SCVA.flac case01d "-P 1234"
 
1159
# case 01e: on file with no PADDING blocks and no -P given, use default padding
 
1160
flac2flac input-SCVA.flac case01e ""
 
1161
# case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
 
1162
flac2flac input-SCPAP.flac case02a ""
 
1163
# case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
 
1164
flac2flac 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
 
1166
flac2flac input-SCVAUP.flac case02c "$TOTALLY_SILENT --tag=artist=0"
 
1167
# case 03a: on file with no CUESHEET block and --cuesheet specified, add it
 
1168
flac2flac input-SVAUP.flac case03a "--cuesheet=input0.cue"
 
1169
# case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
 
1170
flac2flac 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
 
1172
flac2flac input-SCVAUP.flac case03c "$TOTALLY_SILENT --skip=1"
 
1173
# case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
 
1174
flac2flac input-VA.flac case04a "--no-padding --no-seektable"
 
1175
# case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
 
1176
flac2flac 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
 
1178
flac2flac input-VA.flac case04c "--no-padding"
 
1179
# case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
 
1180
flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
 
1181
# case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
 
1182
flac2flac 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
 
 
1186
rm -f out.flac out.meta
 
1187
 
 
1188
#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
 
1189
 
 
1190
cd ..