#!/bin/sh
# FLAC - Free Lossless Audio Codec
-# Copyright (C) 2001,2002,2003,2004,2005,2006 Josh Coalson
+# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
#
# This file is part the FLAC project. FLAC is comprised of several
# components distributed under difference licenses. The codec libraries
exit 1
}
+dddie="die ERROR: creating files with dd"
+
if [ x = x"$1" ] ; then
BUILD=debug
else
run_flac ()
{
if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
- valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
+ echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_flac.valgrind.log
+ valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 flac $* 4>>test_flac.valgrind.log
else
flac $*
fi
run_metaflac ()
{
if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
- valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_flac.valgrind.log
+ echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 metaflac $*" >>test_flac.valgrind.log
+ valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 metaflac $* 4>>test_flac.valgrind.log
else
metaflac $*
fi
rm -f exist.wav exist.flac
############################################################################
+# test fractional block sizes
+############################################################################
+
+test_fractional ()
+{
+ blocksize=$1
+ samples=$2
+ dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie
+ echo -n "fractional block size test (blocksize=$blocksize samples=$samples) encode... "
+ 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"
+ echo -n "decode... "
+ run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o pbs.cmp pbs.flac || die "ERROR"
+ echo -n "compare... "
+ cmp pbs.raw pbs.cmp || die "ERROR: file mismatch"
+ echo "OK"
+ rm -f pbs.raw pbs.flac pbs.cmp
+}
+
+# The special significance of 2048 is it's the # of samples that flac calls
+# FLAC__stream_encoder_process() on.
+#
+# We're trying to make sure the 1-sample overread logic in the stream encoder
+# (used for last-block checking) works; these values probe around common
+# multiples of the flac sample chunk size (2048) and the blocksize.
+for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do
+ test_fractional 33 $samples
+done
+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
+ test_fractional 256 $samples
+done
+for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
+ test_fractional 2048 $samples
+done
+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
+ test_fractional 4608 $samples
+done
+
+############################################################################
# basic 'round-trip' tests of various kinds of streams
############################################################################
channels=`echo $f | awk -F- '{print $2}'`
bps=`echo $f | awk -F- '{print $3}'`
echo -n "round-trip test ($f) encode... "
- run_flac $SILENT --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels --lax -o rt.flac $f || die "ERROR"
+ 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"
echo -n "decode... "
run_flac $SILENT --force --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
echo -n "compare... "
{
f="$1"
echo -n "round-trip test ($f) encode... "
- run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
+ run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
echo -n "decode... "
run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt.flac || die "ERROR"
echo -n "compare... "
{
f="$1"
echo -n "round-trip test ($f) encode... "
- run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
+ run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
echo -n "decode... "
run_flac $SILENT --force --decode --channel-map=none -o rt.aiff rt.flac || die "ERROR"
echo -n "compare... "
{
f="$1"
echo -n "round-trip test ($f->flac->flac->wav) encode... "
- run_flac $SILENT --force --verify --channel-map=none --lax -o rt.flac $f || die "ERROR"
+ run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.flac $f || die "ERROR"
echo -n "re-encode... "
run_flac $SILENT --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
echo -n "decode... "
rm -f rt.wav rt.flac rt2.flac
}
+# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
+rt_test_ogg_flac ()
+{
+ f="$1"
+ echo -n "round-trip test ($f->oggflac->oggflac->wav) encode... "
+ run_flac $SILENT --force --verify --channel-map=none --no-padding --lax -o rt.ogg --ogg $f || die "ERROR"
+ echo -n "re-encode... "
+ run_flac $SILENT --force --verify --lax -o rt2.ogg --ogg rt.ogg || die "ERROR"
+ echo -n "decode... "
+ run_flac $SILENT --force --decode --channel-map=none -o rt.wav rt2.ogg || die "ERROR"
+ echo -n "compare... "
+ cmp $f rt.wav || die "ERROR: file mismatch"
+ echo "OK"
+ rm -f rt.wav rt.ogg rt2.ogg
+}
+
for f in rt-*.raw ; do
rt_test_raw $f
done
for f in rt-*.wav ; do
rt_test_flac $f
done
+if [ $has_ogg = yes ] ; then
+ for f in rt-*.wav ; do
+ rt_test_ogg_flac $f
+ done
+fi
############################################################################
# test --skip and --until
# first make some chopped-up raw files
#
echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
-dddie="die ERROR: creating files with dd"
dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
-wav_eopt="$SILENT --force --verify --lax"
+wav_eopt="$SILENT --force --verify --no-padding --lax"
wav_dopt="$SILENT --force --decode"
raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
#
-# convert them to WAVE and AIFF files
+# convert them to WAVE/AIFF/Ogg FLAC files
#
convert_to_wav ()
{
convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
+convert_to_ogg ()
+{
+ run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
+}
+if [ $has_ogg = yes ] ; then
+ convert_to_ogg 50c
+ convert_to_ogg 50c.skip10
+ convert_to_ogg 50c.skip11
+ convert_to_ogg 50c.skip20
+ convert_to_ogg 50c.skip30
+ convert_to_ogg 50c.skip40
+ convert_to_ogg 50c.until10
+ convert_to_ogg 50c.until20
+ convert_to_ogg 50c.until30
+ convert_to_ogg 50c.until39
+ convert_to_ogg 50c.until40
+ convert_to_ogg 50c.skip10.until30
+ convert_to_ogg 50c.skip10.until39
+ convert_to_ogg 50c.skip10.until40
+ convert_to_ogg 50c.skip20.until30
+ convert_to_ogg 50c.skip20.until40
+fi
+
test_skip_until ()
{
in_fmt=$1
out_fmt=$2
- [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
+ [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
[ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
dopt="$wav_dopt"
fi
- if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
+ if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
CMP=md5cmp
else
CMP=cmp
test_skip_until wav flac
test_skip_until aiff flac
test_skip_until flac flac
+#@@@if [ $has_ogg = yes ] ; then
+#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
+#@@@ test_skip_until ogg flac
+#@@@fi
-if [ $has_ogg = "yes" ] ; then
+if [ $has_ogg = yes ] ; then
test_skip_until raw ogg
test_skip_until wav ogg
test_skip_until aiff ogg
- #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
+ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
#@@@test_skip_until flac ogg
+ #@@@test_skip_until ogg ogg
fi
echo "testing seek extremes:"
-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"
+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"
if [ $is_win = no ] ; then
total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
in_fmt=$1
out_fmt=$2
- [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
+ [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
[ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
dopt="$wav_dopt"
fi
- if [ $in_fmt = flac ] && [ $out_fmt = flac ] ; then
+ if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
CMP=md5cmp
else
CMP=cmp
test_cue wav flac
test_cue aiff flac
test_cue flac flac
+#@@@if [ $has_ogg = yes ] ; then
+#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
+#@@@ test_cue ogg flac
+#@@@fi
-if [ $has_ogg = "yes" ] ; then
+if [ $has_ogg = yes ] ; then
test_cue raw ogg
test_cue wav ogg
test_cue aiff ogg
- #@@@ doesn't work yet, no comparison step written since metaflac doesn't work on ogg flac yet
+ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
#@@@test_cue flac ogg
+ #@@@test_cue ogg ogg
fi
############################################################################
echo "Generating multiple input files from noise..."
multifile_format_decode="--endian=big --sign=signed"
-multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2"
+multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding"
short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
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"
run_flac --decode --force $SILENT shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
encode_options="$encode_options --sector-align"
fi
- if [ $input_type = flac ] ; then
+ if [ $input_type = flac ] || [ $input_type = ogg ] ; then
CMP=md5cmp
else
CMP=cmp
done
}
-for input_type in raw wav aiff flac ; do
+input_types="raw wav aiff flac"
+#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
+#@@@if [ $has_ogg = yes ] ; then
+#@@@ input_types="$input_types ogg"
+#@@@fi
+for input_type in $input_types ; do
echo "Testing multiple $input_type files without verify..."
test_multifile $input_type flac no_sector_align ""
echo "Testing multiple $input_type files with verify..."
test_multifile $input_type flac no_sector_align "--verify"
- if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
+ if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
echo "Testing multiple $input_type files with --sector-align, without verify..."
test_multifile $input_type flac sector_align ""
test_multifile $input_type flac sector_align "--verify"
fi
- if [ $has_ogg = "yes" ] ; then
+ if [ $has_ogg = yes ] ; then
echo "Testing multiple $input_type files with --ogg, without verify..."
test_multifile $input_type ogg no_sector_align ""
testdir="flac-to-flac-metadata-test-files"
filter ()
{
- # minor danger, changing vendor strings will change the length of the
+ # minor danger, changing vendor strings might change the length of the
# VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
# we lose info about PADDING size that we need
grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
rm -f out.flac out.meta
+#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
+
cd ..