6507a448aba2a8c494c33a10d809a457f8e2f297
[flac.git] / test / test_compression.sh
1 #!/bin/sh
2
3 #  FLAC - Free Lossless Audio Codec
4 #  Copyright (C) 2012  Xiph.Org Foundation
5 #
6 #  This file is part the FLAC project.  FLAC is comprised of several
7 #  components distributed under difference licenses.  The codec libraries
8 #  are distributed under Xiph.Org's BSD-like license (see the file
9 #  COPYING.Xiph in this distribution).  All other programs, libraries, and
10 #  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
11 #  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
12 #  FLAC distribution contains at the top the terms under which it may be
13 #  distributed.
14 #
15 #  Since this particular file is relevant to all components of FLAC,
16 #  it may be distributed under the Xiph.Org license, which is the least
17 #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
18 #  distribution.
19
20 LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
21 LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
22 LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
23 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
24 LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
25 LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
26 LD_LIBRARY_PATH=`pwd`/../obj/$BUILD/lib:$LD_LIBRARY_PATH
27 export LD_LIBRARY_PATH
28 PATH=`pwd`/../src/flac:$PATH
29
30 echo "Using FLAC binary :" `which flac`
31
32 date=`date "+%Y%m%dT%H%M%S"`
33 fname="comp${date}.flac"
34
35 last_size=0
36 last_k=0
37 for k in `seq 1 8` ; do
38         flac -${k} --silent noisy-sine.wav -o ${fname}
39         size=`stat --format="%s" ${fname}`
40         echo "Compression level ${k}, file size ${size} bytes."
41         if test $k -gt 1 ; then
42                 if test $last_size -lt $size ; then
43                         echo "Error : Compression $last_k size $last_size >= compression $k size $size."
44                         exit 1
45                         fi
46                 fi
47         last_size=$size
48         last_k=$k
49         rm -f $fname
50         done