blob: f4cbd0062b02fdddecc332db6134b98ab2965a32 [file] [log] [blame]
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +11001#!/bin/sh -e
Josh Coalsonbb7f6b92000-12-10 04:09:52 +00002
Josh Coalson6b05bc52001-06-08 00:13:21 +00003# FLAC - Free Lossless Audio Codec
Erik de Castro Lopob1982fb2013-05-25 17:11:19 +10004# Copyright (C) 2001-2009 Josh Coalson
Erik de Castro Lopo6a5fe432016-12-05 06:35:39 +11005# Copyright (C) 2011-2016 Xiph.Org Foundation
Josh Coalson6b05bc52001-06-08 00:13:21 +00006#
Josh Coalsone8a76012003-02-07 00:14:32 +00007# This file is part the FLAC project. FLAC is comprised of several
Ulrich Klauercd4ddab2013-05-26 22:53:43 +02008# components distributed under different licenses. The codec libraries
Josh Coalsone8a76012003-02-07 00:14:32 +00009# are distributed under Xiph.Org's BSD-like license (see the file
10# COPYING.Xiph in this distribution). All other programs, libraries, and
11# plugins are distributed under the GPL (see COPYING.GPL). The documentation
12# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
13# FLAC distribution contains at the top the terms under which it may be
14# distributed.
Josh Coalson6b05bc52001-06-08 00:13:21 +000015#
Josh Coalsone8a76012003-02-07 00:14:32 +000016# Since this particular file is relevant to all components of FLAC,
17# it may be distributed under the Xiph.Org license, which is the least
18# restrictive of those mentioned above. See the file COPYING.Xiph in this
19# distribution.
Josh Coalson6b05bc52001-06-08 00:13:21 +000020
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +110021. ./common.sh
Josh Coalson6218b342002-12-12 03:58:18 +000022
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000023PATH=../src/flac:$PATH
24PATH=../src/test_streams:$PATH
Erik de Castro Lopo85d5c532013-01-02 22:37:42 +110025PATH=../objs/$BUILD/bin:$PATH
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000026
Josh Coalson4ac9fdb2006-11-02 01:38:55 +000027if [ x"$FLAC__TEST_LEVEL" = x ] ; then
28 FLAC__TEST_LEVEL=1
29fi
30
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100031flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalsonbc869502002-06-14 06:36:16 +000032
Josh Coalson34c1ea82002-12-04 04:57:33 +000033run_flac ()
34{
Josh Coalsonde9091e2006-05-25 02:48:22 +000035 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020036 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_streams.valgrind.log
Erik de Castro Lopod06d9852013-08-01 23:02:26 +100037 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_streams.valgrind.log
Josh Coalson34c1ea82002-12-04 04:57:33 +000038 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100039 flac${EXE} --no-error-on-compression-fail $*
Josh Coalson34c1ea82002-12-04 04:57:33 +000040 fi
41}
42
Josh Coalsonf6237c82001-02-28 23:43:29 +000043echo "Generating streams..."
Josh Coalsond3fe7282002-12-10 06:42:15 +000044if [ ! -f wacky1.wav ] ; then
Erik de Castro Lopobb6f6432015-09-09 15:49:11 +100045 test_streams || die "ERROR: missing files"
Josh Coalson9bcf9e82002-08-07 17:07:37 +000046fi
47
Josh Coalson9bcf9e82002-08-07 17:07:37 +000048#
Josh Coalsond3fe7282002-12-10 06:42:15 +000049# single-file test routines
Josh Coalson9bcf9e82002-08-07 17:07:37 +000050#
51
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000052test_file ()
53{
54 name=$1
55 channels=$2
56 bps=$3
57 encode_options="$4"
58
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +110059 echo $ECHO_N "$name (--channels=$channels --bps=$bps $encode_options): encode..." $ECHO_C
Josh Coalson5ebd6932006-11-17 06:03:18 +000060 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.raw"
Josh Coalson29b4af82001-02-08 22:00:05 +000061 echo "### ENCODE $name #######################################################" >> ./streams.log
62 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000063 $cmd 2>>./streams.log || die "ERROR during encode of $name"
64
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +110065 echo $ECHO_N "decode..." $ECHO_C
Josh Coalson439367c2005-02-03 04:20:16 +000066 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac"
Josh Coalson29b4af82001-02-08 22:00:05 +000067 echo "### DECODE $name #######################################################" >> ./streams.log
68 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000069 $cmd 2>>./streams.log || die "ERROR during decode of $name"
70
Josh Coalson29b4af82001-02-08 22:00:05 +000071 ls -1l $name.raw >> ./streams.log
72 ls -1l $name.flac >> ./streams.log
73 ls -1l $name.cmp >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000074
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +110075 echo $ECHO_N "compare..." $ECHO_C
Josh Coalson6218b342002-12-12 03:58:18 +000076 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
77
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000078 echo OK
79}
80
Josh Coalsona59ff6f2002-06-10 18:24:51 +000081test_file_piped ()
82{
83 name=$1
84 channels=$2
85 bps=$3
86 encode_options="$4"
87
Josh Coalsond57c8d32002-06-11 06:15:28 +000088 if [ `env | grep -ic '^comspec='` != 0 ] ; then
89 is_win=yes
90 else
91 is_win=no
92 fi
93
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +110094 echo $ECHO_N "$name: encode via pipes..." $ECHO_C
Josh Coalsond57c8d32002-06-11 06:15:28 +000095 if [ $is_win = yes ] ; then
Josh Coalson5ebd6932006-11-17 06:03:18 +000096 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout $name.raw"
Josh Coalsond57c8d32002-06-11 06:15:28 +000097 echo "### ENCODE $name #######################################################" >> ./streams.log
98 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +000099 $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000100 else
Josh Coalson5ebd6932006-11-17 06:03:18 +0000101 cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout -"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000102 echo "### ENCODE $name #######################################################" >> ./streams.log
103 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000104 cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000105 fi
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +1100106 echo $ECHO_N "decode via pipes..." $ECHO_C
Josh Coalsond57c8d32002-06-11 06:15:28 +0000107 if [ $is_win = yes ] ; then
Josh Coalson439367c2005-02-03 04:20:16 +0000108 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000109 echo "### DECODE $name #######################################################" >> ./streams.log
110 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000111 $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000112 else
Josh Coalson439367c2005-02-03 04:20:16 +0000113 cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -"
Josh Coalsond57c8d32002-06-11 06:15:28 +0000114 echo "### DECODE $name #######################################################" >> ./streams.log
115 echo "### cmd=$cmd" >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000116 cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000117 fi
118 ls -1l $name.raw >> ./streams.log
119 ls -1l $name.flac >> ./streams.log
120 ls -1l $name.cmp >> ./streams.log
Josh Coalson6218b342002-12-12 03:58:18 +0000121
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +1100122 echo $ECHO_N "compare..." $ECHO_C
Josh Coalson6218b342002-12-12 03:58:18 +0000123 cmp $name.raw $name.cmp || die "ERROR during compare of $name"
124
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000125 echo OK
126}
127
Josh Coalsonde9091e2006-05-25 02:48:22 +0000128if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalson9b145182002-08-30 05:39:36 +0000129 max_lpc_order=32
130else
131 max_lpc_order=16
132fi
133
Josh Coalsona59ff6f2002-06-10 18:24:51 +0000134echo "Testing noise through pipes..."
135test_file_piped noise 1 8 "-0"
136
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000137echo "Testing small files..."
Josh Coalsond0edb972006-10-07 06:50:08 +0000138test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
139test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
140test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
141test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000142
Josh Coalson574dc9c2007-01-19 05:33:30 +0000143for bps in 8 16 24 ; do
144 echo "Testing $bps-bit full-scale deflection streams..."
145 for b in 01 02 03 04 05 06 07 ; do
146 test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p"
147 done
Josh Coalson29b4af82001-02-08 22:00:05 +0000148done
Josh Coalsonf6237c82001-02-28 23:43:29 +0000149
Josh Coalsond0418492001-03-27 23:58:23 +0000150echo "Testing 16-bit wasted-bits-per-sample streams..."
151for b in 01 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000152 test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
Josh Coalsond0418492001-03-27 23:58:23 +0000153done
154
Josh Coalson9fb180b2002-08-22 07:26:06 +0000155for bps in 8 16 24 ; do
Josh Coalsonf6237c82001-02-28 23:43:29 +0000156 echo "Testing $bps-bit sine wave streams..."
Josh Coalson9fb180b2002-08-22 07:26:06 +0000157 for b in 00 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000158 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000159 done
160 for b in 01 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000161 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000162 done
163 for b in 02 03 04 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000164 test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e"
Josh Coalsonf6237c82001-02-28 23:43:29 +0000165 done
Josh Coalson9fb180b2002-08-22 07:26:06 +0000166 for b in 10 11 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000167 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000168 done
169 for b in 12 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000170 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
Josh Coalson9fb180b2002-08-22 07:26:06 +0000171 done
172 for b in 13 14 15 16 17 18 19 ; do
Josh Coalsond0edb972006-10-07 06:50:08 +0000173 test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e"
Josh Coalsonf6237c82001-02-28 23:43:29 +0000174 done
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000175done
176
Josh Coalson94b22e02002-10-11 06:22:30 +0000177echo "Testing blocksize variations..."
178for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
179 for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
180 for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do
181 if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then
Josh Coalson574dc9c2007-01-19 05:33:30 +0000182 test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable"
Josh Coalson94b22e02002-10-11 06:22:30 +0000183 fi
184 done
185 done
186done
187
Josh Coalsonbb7f6b92000-12-10 04:09:52 +0000188echo "Testing some frame header variations..."
Josh Coalson9b145182002-08-30 05:39:36 +0000189test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order"
190test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535"
191test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
192test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
193test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
Josh Coalsone2281f32002-09-11 00:31:47 +0000194test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
195test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
196test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
Josh Coalson29b4af82001-02-08 22:00:05 +0000197
198echo "Testing option variations..."
199for f in 00 01 02 03 04 ; do
Josh Coalson94b22e02002-10-11 06:22:30 +0000200 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000201 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
202 for opt in 0 1 2 4 5 6 8 ; do
203 for extras in '' '-p' '-e' ; do
204 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
205 test_file sine16-$f 1 16 "-$opt $extras $disable"
206 fi
207 done
Josh Coalson29b4af82001-02-08 22:00:05 +0000208 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000209 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000210 test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000211 fi
Josh Coalson9b145182002-08-30 05:39:36 +0000212 fi
Josh Coalson29b4af82001-02-08 22:00:05 +0000213 done
214done
Josh Coalson94b22e02002-10-11 06:22:30 +0000215
216for f in 10 11 12 13 14 15 16 17 18 19 ; do
217 for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000218 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
219 for opt in 0 1 2 4 5 6 8 ; do
220 for extras in '' '-p' '-e' ; do
221 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
222 test_file sine16-$f 2 16 "-$opt $extras $disable"
223 fi
224 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000225 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000226 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000227 test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000228 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000229 fi
230 done
231done
232
233echo "Testing noise..."
234for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
Josh Coalsonde9091e2006-05-25 02:48:22 +0000235 if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
236 for channels in 1 2 4 8 ; do
237 if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
238 for bps in 8 16 24 ; do
239 for opt in 0 1 2 3 4 5 6 7 8 ; do
240 for extras in '' '-p' '-e' ; do
241 if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
242 for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
243 if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
244 test_file noise $channels $bps "-$opt $extras $blocksize $disable"
245 fi
246 done
247 fi
248 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000249 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000250 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
Josh Coalsond0edb972006-10-07 06:50:08 +0000251 test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
Josh Coalsonde9091e2006-05-25 02:48:22 +0000252 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000253 done
Josh Coalson94b22e02002-10-11 06:22:30 +0000254 fi
255 done
Josh Coalsonde9091e2006-05-25 02:48:22 +0000256 fi
Josh Coalson94b22e02002-10-11 06:22:30 +0000257done