2002-06-14 10:31:35 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# FLAC - Free Lossless Audio Codec
|
2009-01-07 10:31:28 +03:00
|
|
|
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
|
2002-06-14 10:31:35 +04:00
|
|
|
#
|
2003-02-07 03:14:32 +03:00
|
|
|
# This file is part the FLAC project. FLAC is comprised of several
|
|
|
|
# components distributed under difference licenses. The codec libraries
|
|
|
|
# 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.
|
2002-06-14 10:31:35 +04:00
|
|
|
#
|
2003-02-07 03:14:32 +03:00
|
|
|
# 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.
|
2002-06-14 10:31:35 +04:00
|
|
|
|
2002-12-12 06:58:18 +03:00
|
|
|
die ()
|
|
|
|
{
|
|
|
|
echo $* 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
if [ x = x"$1" ] ; then
|
2004-11-09 04:28:05 +03:00
|
|
|
BUILD=debug
|
|
|
|
else
|
|
|
|
BUILD="$1"
|
|
|
|
fi
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
# change to 'false' to show all flac/metaflac output (useful for debugging)
|
|
|
|
if true ; then
|
|
|
|
SILENT='--silent'
|
|
|
|
TOTALLY_SILENT='--totally-silent'
|
|
|
|
else
|
|
|
|
SILENT=''
|
|
|
|
TOTALLY_SILENT=''
|
|
|
|
fi
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
|
|
|
|
LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
|
2013-01-02 15:37:42 +04:00
|
|
|
LD_LIBRARY_PATH=`pwd`/../objs/$BUILD/lib:$LD_LIBRARY_PATH
|
2002-06-14 10:31:35 +04:00
|
|
|
export LD_LIBRARY_PATH
|
2012-04-18 05:12:45 +04:00
|
|
|
export MALLOC_CHECK_=3
|
2013-04-25 06:31:50 +04:00
|
|
|
export MALLOC_PERTURB_=$((1$(date +%N) % 255 + 1))
|
2006-08-28 07:39:45 +04:00
|
|
|
PATH=`pwd`/../src/flac:$PATH
|
|
|
|
PATH=`pwd`/../src/metaflac:$PATH
|
2013-01-02 15:37:42 +04:00
|
|
|
PATH=`pwd`/../objs/$BUILD/bin:$PATH
|
2002-06-14 10:31:35 +04:00
|
|
|
|
2007-08-29 04:38:16 +04:00
|
|
|
if echo a | (grep -E '(a|b)') >/dev/null 2>&1
|
|
|
|
then EGREP='grep -E'
|
|
|
|
else EGREP='egrep'
|
|
|
|
fi
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
testdir="metaflac-test-files"
|
|
|
|
flacfile="metaflac.flac"
|
2002-06-14 10:31:35 +04:00
|
|
|
|
2002-12-12 06:58:18 +03:00
|
|
|
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
|
|
|
|
metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2002-12-04 07:57:33 +03:00
|
|
|
run_flac ()
|
|
|
|
{
|
2006-05-25 06:48:22 +04:00
|
|
|
if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_metaflac.valgrind.log
|
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac $* 4>>test_metaflac.valgrind.log
|
2002-12-04 07:57:33 +03:00
|
|
|
else
|
|
|
|
flac $*
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run_metaflac ()
|
|
|
|
{
|
2006-05-25 06:48:22 +04:00
|
|
|
if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log
|
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_metaflac.valgrind.log
|
2002-12-04 07:57:33 +03:00
|
|
|
else
|
|
|
|
metaflac $*
|
|
|
|
fi
|
|
|
|
}
|
2002-10-11 10:22:43 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac_silent ()
|
|
|
|
{
|
|
|
|
if [ -z "$SILENT" ] ; then
|
|
|
|
run_metaflac $*
|
|
|
|
else
|
|
|
|
if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
|
2013-04-22 01:12:16 +04:00
|
|
|
echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log
|
|
|
|
valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 2>/dev/null 4>>test_metaflac.valgrind.log
|
2006-08-28 07:39:45 +04:00
|
|
|
else
|
|
|
|
metaflac $* 2>/dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_flac ()
|
|
|
|
{
|
|
|
|
run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
|
|
|
|
}
|
|
|
|
|
2002-06-15 09:14:04 +04:00
|
|
|
echo "Generating stream..."
|
2006-08-28 07:39:45 +04:00
|
|
|
bytes=80000
|
|
|
|
if dd if=/dev/zero ibs=1 count=$bytes | flac --force --verify -0 --input-size=$bytes --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=8000 - ; then
|
2002-06-15 09:14:04 +04:00
|
|
|
chmod +w $flacfile
|
|
|
|
else
|
2002-12-12 06:58:18 +03:00
|
|
|
die "ERROR during generation"
|
2002-06-14 10:31:35 +04:00
|
|
|
fi
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
check_flac
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
filter ()
|
2002-06-14 10:31:35 +04:00
|
|
|
{
|
2006-08-28 07:39:45 +04:00
|
|
|
# minor danger, changing vendor strings will 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
|
2006-09-26 04:43:48 +04:00
|
|
|
# grep pattern 1: remove vendor string
|
|
|
|
# grep pattern 2: remove minimum/maximum frame and block size from STREAMINFO
|
|
|
|
# grep pattern 3: remove hexdump data from PICTURE metadata blocks
|
|
|
|
# sed pattern 1: remove stream offset values from SEEKTABLE points
|
2007-08-29 04:38:16 +04:00
|
|
|
$EGREP -v '^ vendor string: |^ m..imum .....size: |^ 0000[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]: ' | sed -e 's/, stream_offset.*//'
|
2002-06-14 10:31:35 +04:00
|
|
|
}
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test ()
|
2002-06-14 10:31:35 +04:00
|
|
|
{
|
2006-08-28 07:39:45 +04:00
|
|
|
case="$1"
|
|
|
|
desc="$2"
|
|
|
|
args="$3"
|
|
|
|
expect="$testdir/$case-expect.meta"
|
|
|
|
echo -n "test $case: $desc... "
|
|
|
|
run_metaflac $args $flacfile | filter > $testdir/out.meta || die "ERROR running metaflac"
|
2007-08-29 04:38:16 +04:00
|
|
|
diff -w $expect $testdir/out.meta > /dev/null 2>&1 || die "ERROR: metadata does not match expected $expect"
|
2006-08-28 07:39:45 +04:00
|
|
|
echo OK
|
2002-06-14 10:31:35 +04:00
|
|
|
}
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case00 "--list" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case01 "STREAMINFO --show-* shortcuts" "
|
|
|
|
--show-md5sum
|
|
|
|
--show-min-blocksize
|
|
|
|
--show-max-blocksize
|
|
|
|
--show-min-framesize
|
|
|
|
--show-max-framesize
|
|
|
|
--show-sample-rate
|
|
|
|
--show-channels
|
|
|
|
--show-bps
|
|
|
|
--show-total-samples"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --preserve-modtime --add-padding=12345 $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case02 "--add-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2002-10-26 08:28:11 +04:00
|
|
|
# some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore:
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case03 "--set-tag=ARTIST" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case04 "--set-tag=ARTIST" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --set-tag="ARTIST=Vern" $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case05 "--set-tag=ARTIST" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case06 "--set-tag=TITLE" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case07 "--show-vendor-tag --show-tag=ARTIST" "--show-vendor-tag --show-tag=ARTIST"
|
2002-10-26 08:28:11 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-first-tag=ARTIST $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case08 "--remove-first-tag=ARTIST" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-tag=ARTIST $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case09 "--remove-tag=ARTIST" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case10 "--list --block-type=VORBIS_COMMENT" "--list --block-type=VORBIS_COMMENT"
|
|
|
|
metaflac_test case11 "--list --block-number=0" "--list --block-number=0"
|
|
|
|
metaflac_test case12 "--list --block-number=1,2,999" "--list --block-number=1,2,999"
|
|
|
|
metaflac_test case13 "--list --block-type=VORBIS_COMMENT,PADDING" "--list --block-type=VORBIS_COMMENT,PADDING"
|
|
|
|
metaflac_test case14 "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT" "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT"
|
|
|
|
metaflac_test case15 "--list --except-block-type=STREAMINFO" "--list --except-block-type=STREAMINFO"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --add-padding=4321 $flacfile $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case16 "--add-padding=4321 * 2" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --merge-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case17 "--merge-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --add-padding=0 $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case18 "--add-padding=0" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --sort-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case19 "--sort-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --add-padding=0 $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case20 "--add-padding=0" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case21 "--remove-all-tags" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case22 "--remove --block-number=1,99 --dont-use-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove --block-number=99 --dont-use-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case23 "--remove --block-number=99 --dont-use-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove --block-type=PADDING $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case24 "--remove --block-type=PADDING" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case25 "--remove --block-type=PADDING --dont-use-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --add-padding=0 $flacfile $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case26 "--add-padding=0 * 2" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove --except-block-type=PADDING $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case27 "--remove --except-block-type=PADDING" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case28 "--remove-all" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all --dont-use-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case29 "--remove-all --dont-use-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all --dont-use-padding $flacfile
|
2002-06-15 09:14:04 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case30 "--remove-all --dont-use-padding" "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case31 "--set-tag=..." "--list"
|
2002-06-15 09:14:04 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case32 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case33 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case34 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case35 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case36 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case37 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile
|
2002-06-18 09:25:41 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case38 "--remove-all-tags --set-tag=..." "--list"
|
2002-06-18 09:25:41 +04:00
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile
|
2002-09-05 09:38:22 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case39 "--import-tags-from=-" "--list"
|
2002-09-05 09:38:22 +04:00
|
|
|
|
|
|
|
cat > vc.txt << EOF
|
|
|
|
artist=Fartist
|
|
|
|
artist=artits
|
|
|
|
EOF
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --import-tags-from=vc.txt $flacfile
|
2002-09-05 09:38:22 +04:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case40 "--import-tags-from=[FILE]" "--list"
|
2002-09-05 09:38:22 +04:00
|
|
|
|
|
|
|
rm vc.txt
|
|
|
|
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --add-replay-gain $flacfile
|
|
|
|
check_flac
|
|
|
|
metaflac_test case41 "--add-replay-gain" "--list"
|
|
|
|
|
|
|
|
run_metaflac --remove-replay-gain $flacfile
|
|
|
|
check_flac
|
|
|
|
metaflac_test case42 "--remove-replay-gain" "--list"
|
|
|
|
|
2006-09-26 04:43:48 +04:00
|
|
|
# CUESHEET blocks
|
2002-11-27 07:46:14 +03:00
|
|
|
cs_in=cuesheets/good.000.cue
|
|
|
|
cs_out=metaflac.cue
|
|
|
|
cs_out2=metaflac2.cue
|
2006-08-28 07:39:45 +04:00
|
|
|
run_metaflac --import-cuesheet-from="$cs_in" $flacfile
|
2002-11-27 07:46:14 +03:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case43 "--import-cuesheet-from" "--list"
|
|
|
|
run_metaflac --export-cuesheet-to=$cs_out $flacfile
|
|
|
|
run_metaflac --remove --block-type=CUESHEET $flacfile
|
2002-11-27 07:46:14 +03:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case44 "--remove --block-type=CUESHEET" "--list"
|
|
|
|
run_metaflac --import-cuesheet-from=$cs_out $flacfile
|
2002-11-27 07:46:14 +03:00
|
|
|
check_flac
|
2006-08-28 07:39:45 +04:00
|
|
|
metaflac_test case45 "--import-cuesheet-from" "--list"
|
|
|
|
run_metaflac --export-cuesheet-to=$cs_out2 $flacfile
|
2002-11-27 07:46:14 +03:00
|
|
|
echo "comparing cuesheets:"
|
2002-12-12 06:58:18 +03:00
|
|
|
diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
|
2002-11-27 07:46:14 +03:00
|
|
|
echo identical
|
|
|
|
|
|
|
|
rm -f $cs_out $cs_out2
|
|
|
|
|
2006-09-26 04:43:48 +04:00
|
|
|
# PICTURE blocks
|
|
|
|
ncase=46
|
|
|
|
for f in \
|
|
|
|
0.gif \
|
|
|
|
1.gif \
|
|
|
|
2.gif \
|
|
|
|
; do
|
2006-11-02 07:06:56 +03:00
|
|
|
run_metaflac --import-picture-from="|image/gif|$f||pictures/$f" $flacfile
|
2006-09-26 04:43:48 +04:00
|
|
|
check_flac
|
2006-11-02 07:06:56 +03:00
|
|
|
metaflac_test "case$ncase" "--import-picture-from" "--list"
|
2006-09-26 04:43:48 +04:00
|
|
|
ncase=`expr $ncase + 1`
|
|
|
|
done
|
|
|
|
for f in \
|
|
|
|
0.jpg \
|
|
|
|
4.jpg \
|
|
|
|
; do
|
2006-11-02 07:06:56 +03:00
|
|
|
run_metaflac --import-picture-from="4|image/jpeg|$f||pictures/$f" $flacfile
|
2006-09-26 04:43:48 +04:00
|
|
|
check_flac
|
2006-11-02 07:06:56 +03:00
|
|
|
metaflac_test "case$ncase" "--import-picture-from" "--list"
|
2006-09-26 04:43:48 +04:00
|
|
|
ncase=`expr $ncase + 1`
|
|
|
|
done
|
|
|
|
for f in \
|
|
|
|
0.png \
|
|
|
|
1.png \
|
|
|
|
2.png \
|
|
|
|
3.png \
|
|
|
|
4.png \
|
|
|
|
5.png \
|
|
|
|
6.png \
|
|
|
|
7.png \
|
|
|
|
8.png \
|
|
|
|
; do
|
2006-11-02 07:06:56 +03:00
|
|
|
run_metaflac --import-picture-from="5|image/png|$f||pictures/$f" $flacfile
|
2006-09-26 04:43:48 +04:00
|
|
|
check_flac
|
2006-11-02 07:06:56 +03:00
|
|
|
metaflac_test "case$ncase" "--import-picture-from" "--list"
|
2006-09-26 04:43:48 +04:00
|
|
|
ncase=`expr $ncase + 1`
|
|
|
|
done
|
2006-10-03 05:02:44 +04:00
|
|
|
[ $ncase = 60 ] || die "expected case# to be 60"
|
2006-11-02 06:40:44 +03:00
|
|
|
|
|
|
|
fn=export-picture-check
|
|
|
|
echo -n "Testing --export-picture-to... "
|
|
|
|
run_metaflac --export-picture-to=$fn $flacfile
|
|
|
|
check_flac
|
|
|
|
cmp $fn pictures/0.gif || die "ERROR, exported picture file and original differ"
|
|
|
|
echo OK
|
|
|
|
rm -f $fn
|
|
|
|
echo -n "Testing --block-number --export-picture-to... "
|
|
|
|
run_metaflac --block-number=9 --export-picture-to=$fn $flacfile
|
|
|
|
check_flac
|
|
|
|
cmp $fn pictures/0.png || die "ERROR, exported picture file and original differ"
|
|
|
|
echo OK
|
|
|
|
rm -f $fn
|
|
|
|
|
2006-09-26 04:43:48 +04:00
|
|
|
run_metaflac --remove --block-type=PICTURE $flacfile
|
|
|
|
check_flac
|
|
|
|
metaflac_test case60 "--remove --block-type=PICTURE" "--list"
|
2006-11-02 07:06:56 +03:00
|
|
|
run_metaflac --import-picture-from="1|image/png|standard_icon|32x32x24|pictures/0.png" $flacfile
|
2006-09-26 04:43:48 +04:00
|
|
|
check_flac
|
2006-11-02 07:06:56 +03:00
|
|
|
metaflac_test case61 "--import-picture-from" "--list"
|
|
|
|
run_metaflac --import-picture-from="2|image/png|icon|64x64x24|pictures/1.png" $flacfile
|
2006-09-26 04:43:48 +04:00
|
|
|
check_flac
|
2006-11-02 07:06:56 +03:00
|
|
|
metaflac_test case62 "--import-picture-from" "--list"
|
2006-09-26 04:43:48 +04:00
|
|
|
|
|
|
|
# UNKNOWN blocks
|
2003-01-11 09:23:16 +03:00
|
|
|
echo -n "Testing FLAC file with unknown metadata... "
|
|
|
|
cp -p metaflac.flac.in $flacfile
|
2003-01-16 10:21:20 +03:00
|
|
|
# remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison:
|
|
|
|
run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile
|
2003-01-11 09:23:16 +03:00
|
|
|
cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
|
|
|
|
echo OK
|
|
|
|
|
2012-03-19 00:44:11 +04:00
|
|
|
# Replay gain tests - Test the rates which have specific filter table entries
|
|
|
|
# and verify that harmonics can be processed correctly.
|
|
|
|
|
|
|
|
tonegenerator ()
|
|
|
|
{
|
2013-04-25 07:53:21 +04:00
|
|
|
# When using GAWK, use --lint=posix to identify non-POSIX awk usages.
|
2012-03-19 00:44:11 +04:00
|
|
|
awk -- '
|
|
|
|
BEGIN {
|
|
|
|
samplerate = '$1';
|
|
|
|
|
|
|
|
tone = 1000;
|
|
|
|
duration = 1;
|
|
|
|
bitspersample = 24;
|
|
|
|
|
2013-04-25 07:53:21 +04:00
|
|
|
samplemidpoint = 1;
|
|
|
|
for (sps = 0 ; sps < bitspersample - 1 ; sps++) {
|
|
|
|
samplemidpoint *= 2;
|
|
|
|
}
|
|
|
|
|
2012-03-19 00:44:11 +04:00
|
|
|
samplerange = samplemidpoint - 1;
|
|
|
|
|
|
|
|
pi = 4 * atan2(1,1);
|
|
|
|
|
|
|
|
for (ix = 0; ix < duration * samplerate; ++ix) {
|
|
|
|
sample = sin(2 * pi * tone * ix / samplerate);
|
|
|
|
sample *= samplerange;
|
|
|
|
sample += samplemidpoint;
|
|
|
|
sample = int(sample);
|
|
|
|
for (bx = 0; bx < bitspersample/8; ++bx) {
|
|
|
|
byte[bx] = sample % 256;
|
|
|
|
sample /= 256;
|
|
|
|
}
|
|
|
|
while (bx--) {
|
|
|
|
printf("%c", byte[bx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}' /dev/null |
|
|
|
|
flac --silent \
|
|
|
|
--endian=big --channels=1 --bps=24 --sample-rate=$1 --sign=unsigned -
|
|
|
|
}
|
|
|
|
|
|
|
|
REPLAYGAIN_FREQ=
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 8000/-12.73"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 12000/-12.98"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 16000/-13.27"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 18900/-13.41"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 22050/-13.77"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 24000/-13.82"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 28000/-14.06"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 32000/-14.08"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 36000/-14.12"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 37800/-14.18"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 44100/-14.17"
|
|
|
|
REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 48000/-14.16:1:2:4"
|
|
|
|
|
2013-04-25 17:20:23 +04:00
|
|
|
set -e
|
|
|
|
|
2012-03-19 00:44:11 +04:00
|
|
|
for ACTION in $REPLAYGAIN_FREQ ; do
|
|
|
|
if [ -n "${ACTION##*:*}" ] ; then
|
|
|
|
HARMONICS=1
|
|
|
|
else
|
|
|
|
HARMONICS="${ACTION#*:}"
|
|
|
|
fi
|
|
|
|
FREQ="${ACTION%%/*}"
|
|
|
|
GAIN="${ACTION#*/}"
|
|
|
|
GAIN="${GAIN%%:*}"
|
|
|
|
while [ -n "$HARMONICS" ] ; do
|
|
|
|
MULTIPLE="${HARMONICS%%:*}"
|
|
|
|
if [ x"$MULTIPLE" = x"$HARMONICS" ] ; then
|
|
|
|
HARMONICS=
|
|
|
|
else
|
|
|
|
HARMONICS="${HARMONICS#*:}"
|
|
|
|
fi
|
|
|
|
RATE=$(($MULTIPLE * FREQ))
|
|
|
|
[ $MULTIPLE -eq 1 -o -n "${REPLAYGAIN_FREQ##* $RATE/*}" ] || break
|
|
|
|
echo -n "Testing FLAC replaygain $RATE ($FREQ x $MULTIPLE) ... "
|
|
|
|
tonegenerator $RATE > $flacfile
|
|
|
|
run_metaflac --add-replay-gain $flacfile
|
|
|
|
run_metaflac --list $flacfile | grep REPLAYGAIN.*GAIN= |
|
|
|
|
while read -r REPLAYGAIN ; do
|
|
|
|
MEASUREDGAIN="${REPLAYGAIN##*=}"
|
|
|
|
MEASUREDGAIN="${MEASUREDGAIN%% *}"
|
|
|
|
if [ x"$MEASUREDGAIN" != x"$GAIN" ] ; then
|
|
|
|
die "ERROR, Expected $GAIN db instead of $REPLAYGAIN"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo OK
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2006-09-26 04:43:48 +04:00
|
|
|
rm -f $testdir/out.flac $testdir/out.meta
|
2006-08-28 07:39:45 +04:00
|
|
|
|
2002-06-18 09:25:41 +04:00
|
|
|
exit 0
|