2014-11-27 05:03:13 +03:00
|
|
|
#!/bin/sh -e
|
2004-11-09 04:27:12 +03:00
|
|
|
|
|
|
|
# FLAC - Free Lossless Audio Codec
|
2013-05-25 11:11:19 +04:00
|
|
|
# Copyright (C) 2004-2009 Josh Coalson
|
2024-07-11 16:35:32 +03:00
|
|
|
# Copyright (C) 2011-2024 Xiph.Org Foundation
|
2004-11-09 04:27:12 +03:00
|
|
|
#
|
|
|
|
# This file is part the FLAC project. FLAC is comprised of several
|
2013-05-27 00:53:43 +04:00
|
|
|
# components distributed under different licenses. The codec libraries
|
2004-11-09 04:27:12 +03:00
|
|
|
# are distributed under Xiph.Org's BSD-like license (see the file
|
|
|
|
# COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
|
|
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
|
|
|
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
|
|
|
# FLAC distribution contains at the top the terms under which it may be
|
|
|
|
# distributed.
|
|
|
|
#
|
|
|
|
# Since this particular file is relevant to all components of FLAC,
|
|
|
|
# it may be distributed under the Xiph.Org license, which is the least
|
|
|
|
# restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
|
|
# distribution.
|
|
|
|
|
2014-11-27 05:03:13 +03:00
|
|
|
. ./common.sh
|
2004-11-09 04:27:12 +03:00
|
|
|
|
|
|
|
PATH=../src/flac:$PATH
|
2005-01-26 06:48:06 +03:00
|
|
|
PATH=../src/metaflac:$PATH
|
2004-11-09 04:27:12 +03:00
|
|
|
PATH=../src/test_seeking:$PATH
|
|
|
|
PATH=../src/test_streams:$PATH
|
2013-01-02 15:37:42 +04:00
|
|
|
PATH=../objs/$BUILD/bin:$PATH
|
2004-11-09 04:27:12 +03:00
|
|
|
|
2022-05-18 22:27:19 +03:00
|
|
|
if [ -z "$FLAC__TEST_LEVEL" ] ; then
|
2007-06-16 04:43:15 +04:00
|
|
|
FLAC__TEST_LEVEL=1
|
|
|
|
fi
|
|
|
|
|
2013-09-16 13:55:11 +04:00
|
|
|
flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
|
|
|
|
metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
|
2004-11-09 04:27:12 +03:00
|
|
|
|
|
|
|
run_flac ()
|
|
|
|
{
|
2022-05-18 22:27:19 +03:00
|
|
|
if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log
|
2013-09-16 13:55:11 +04:00
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_seeking.valgrind.log
|
2004-11-09 04:27:12 +03:00
|
|
|
else
|
2013-09-16 13:55:11 +04:00
|
|
|
flac${EXE} --no-error-on-compression-fail $*
|
2004-11-09 04:27:12 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-01-26 06:48:06 +03:00
|
|
|
run_metaflac ()
|
|
|
|
{
|
2022-05-18 22:27:19 +03:00
|
|
|
if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log
|
2013-09-16 13:55:11 +04:00
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log
|
2005-01-26 06:48:06 +03:00
|
|
|
else
|
2013-09-16 13:55:11 +04:00
|
|
|
metaflac${EXE} $*
|
2005-01-26 06:48:06 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-11-09 04:27:12 +03:00
|
|
|
run_test_seeking ()
|
|
|
|
{
|
2022-05-18 22:27:19 +03:00
|
|
|
if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log
|
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log
|
2004-11-09 04:27:12 +03:00
|
|
|
else
|
2013-09-16 13:55:11 +04:00
|
|
|
test_seeking${EXE} $*
|
2004-11-09 04:27:12 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-10-04 01:43:33 +03:00
|
|
|
echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C
|
2013-09-16 13:55:11 +04:00
|
|
|
if flac${EXE} --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
|
2005-02-01 04:49:11 +03:00
|
|
|
has_ogg=yes;
|
|
|
|
else
|
|
|
|
has_ogg=no;
|
|
|
|
fi
|
2013-09-15 13:58:35 +04:00
|
|
|
echo ${has_ogg}
|
2004-11-09 04:27:12 +03:00
|
|
|
|
|
|
|
echo "Generating streams..."
|
|
|
|
if [ ! -f noise.raw ] ; then
|
|
|
|
test_streams || die "ERROR during test_streams"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "generating FLAC files for seeking:"
|
2006-09-13 05:42:27 +04:00
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S- --output-name=tiny.flac noise8m32.raw || die "ERROR generating FLAC file"
|
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S- --output-name=small.flac noise.raw || die "ERROR generating FLAC file"
|
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S10x --output-name=tiny-s.flac noise8m32.raw || die "ERROR generating FLAC file"
|
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S10x --output-name=small-s.flac noise.raw || die "ERROR generating FLAC file"
|
|
|
|
|
2022-05-18 22:27:19 +03:00
|
|
|
tiny_samples="$(metaflac${EXE} --show-total-samples tiny.flac)"
|
|
|
|
small_samples="$(metaflac${EXE} --show-total-samples small.flac)"
|
2006-11-16 04:22:33 +03:00
|
|
|
|
2007-06-16 04:43:15 +04:00
|
|
|
tiny_seek_count=100
|
|
|
|
if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
|
|
|
|
small_seek_count=10000
|
|
|
|
else
|
2012-02-26 05:19:39 +04:00
|
|
|
small_seek_count=100
|
2007-06-16 04:43:15 +04:00
|
|
|
fi
|
|
|
|
|
2006-09-13 05:42:27 +04:00
|
|
|
for suffix in '' '-s' ; do
|
|
|
|
echo "testing tiny$suffix.flac:"
|
2007-06-16 04:43:15 +04:00
|
|
|
if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
|
2006-09-13 05:42:27 +04:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
2004-11-09 04:27:12 +03:00
|
|
|
|
2006-09-13 05:42:27 +04:00
|
|
|
echo "testing small$suffix.flac:"
|
2007-06-16 04:43:15 +04:00
|
|
|
if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else
|
2006-09-13 05:42:27 +04:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
2004-11-09 04:27:12 +03:00
|
|
|
|
2006-09-13 05:42:27 +04:00
|
|
|
echo "removing sample count from tiny$suffix.flac and small$suffix.flac:"
|
|
|
|
if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else
|
|
|
|
die "ERROR: during metaflac"
|
|
|
|
fi
|
2005-01-26 06:48:06 +03:00
|
|
|
|
2006-09-13 05:42:27 +04:00
|
|
|
echo "testing tiny$suffix.flac with total_samples=0:"
|
2007-06-16 04:43:15 +04:00
|
|
|
if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
|
2006-09-13 05:42:27 +04:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
2005-01-26 06:48:06 +03:00
|
|
|
|
2006-09-13 05:42:27 +04:00
|
|
|
echo "testing small$suffix.flac with total_samples=0:"
|
2007-06-16 04:43:15 +04:00
|
|
|
if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else
|
2006-09-13 05:42:27 +04:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
|
|
|
done
|
2005-01-26 06:48:06 +03:00
|
|
|
|
2005-02-01 04:49:11 +03:00
|
|
|
if [ $has_ogg = "yes" ] ; then
|
|
|
|
|
2005-09-03 06:16:07 +04:00
|
|
|
echo "generating Ogg FLAC files for seeking:"
|
2007-08-01 07:02:00 +04:00
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.oga --ogg noise8m32.raw || die "ERROR generating Ogg FLAC file"
|
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.oga --ogg noise.raw || die "ERROR generating Ogg FLAC file"
|
2006-10-16 20:18:34 +04:00
|
|
|
# seek tables are not used in Ogg FLAC
|
2005-09-03 06:16:07 +04:00
|
|
|
|
2007-08-01 07:02:00 +04:00
|
|
|
echo "testing tiny.oga:"
|
|
|
|
if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
|
2005-02-01 04:49:11 +03:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
|
|
|
|
2007-08-01 07:02:00 +04:00
|
|
|
echo "testing small.oga:"
|
|
|
|
if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else
|
2005-02-01 04:49:11 +03:00
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
2004-11-09 04:27:12 +03:00
|
|
|
|
2024-08-26 22:49:28 +03:00
|
|
|
echo "generating chained Ogg FLAC files for seeking:"
|
|
|
|
# need to generate a second set with a different serial number
|
|
|
|
tail -c 750000 noise.raw > noise-secondhalf.raw
|
|
|
|
run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small2.oga --ogg noise-secondhalf.raw || die "ERROR generating Ogg FLAC file"
|
|
|
|
|
|
|
|
cat small.oga small2.oga > chained.oga
|
|
|
|
cat noise.raw noise-secondhalf.raw > chained.raw
|
|
|
|
|
|
|
|
echo "testing chained.oga:"
|
|
|
|
chained_samples=$(($small_samples+187500))
|
|
|
|
if run_test_seeking chained.oga $small_seek_count $chained_samples chained.raw ; then : ; else
|
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
|
|
|
|
2024-09-11 15:40:12 +03:00
|
|
|
if command -v oggz > /dev/null ; then
|
|
|
|
if command -v oggenc > /dev/null ; then
|
|
|
|
oggenc -Q --skeleton -o small-vorbis.oga small.flac
|
|
|
|
oggenc -Q --skeleton -o small2-vorbis.oga small.flac
|
|
|
|
oggz merge -o small-merged.oga small-vorbis.oga small.oga
|
|
|
|
oggz merge -o small2-merged.oga small2-vorbis.oga small2.oga
|
|
|
|
cat small2-merged.oga small-merged.oga > chained-merged.oga
|
|
|
|
cat noise-secondhalf.raw noise.raw > chained.raw
|
|
|
|
|
|
|
|
echo "testing chained-merged.oga:"
|
|
|
|
echo run_test_seeking chained-merged.oga $small_seek_count $chained_samples chained.raw
|
|
|
|
if run_test_seeking chained-merged.oga $small_seek_count $chained_samples chained.raw ; then : ; else
|
|
|
|
die "ERROR: during test_seeking"
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2004-11-09 04:27:12 +03:00
|
|
|
fi
|
|
|
|
|
2007-08-01 07:02:00 +04:00
|
|
|
rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac
|