summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test_streams/main.c112
-rwxr-xr-xtest/test_streams.sh10
2 files changed, 114 insertions, 8 deletions
diff --git a/src/test_streams/main.c b/src/test_streams/main.c
index 3cef9561..8c88d941 100644
--- a/src/test_streams/main.c
+++ b/src/test_streams/main.c
@@ -96,13 +96,10 @@ static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x)
;
}
-#if 0
-/* @@@ not used (yet) */
static FLAC__bool write_little_endian_int32(FILE *f, FLAC__int32 x)
{
return write_little_endian_uint32(f, (FLAC__uint32)x);
}
-#endif
#if defined(_MSC_VER)
// silence 4 MSVC warnings 'conversion from 'FLAC__uint64' to 'int', possible loss of data'
@@ -408,6 +405,32 @@ foo:
return false;
}
+/* a mono full-scale deflection 32bps stream */
+static FLAC__bool generate_fsd32(const char *fn, const int pattern[], unsigned reps)
+{
+ FILE *f;
+ unsigned rep, p;
+
+ FLAC__ASSERT(pattern != 0);
+
+ if(0 == (f = fopen(fn, "wb")))
+ return false;
+
+ for(rep = 0; rep < reps; rep++) {
+ for(p = 0; pattern[p]; p++) {
+ FLAC__int32 x = pattern[p] > 0? 2147483647 : -2147483648;
+ if(!write_little_endian_int32(f, x))
+ goto foo;
+ }
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
/* a mono sine-wave 8bps stream */
static FLAC__bool generate_sine8_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2)
{
@@ -582,6 +605,64 @@ foo:
return false;
}
+/* a mono sine-wave 32bps stream */
+static FLAC__bool generate_sine32_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2)
+{
+ const FLAC__int32 full_scale = 0x7fffffff;
+ const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
+ const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
+ FILE *f;
+ double theta1, theta2;
+ unsigned i;
+
+ if(0 == (f = fopen(fn, "wb")))
+ return false;
+
+ for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
+ double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
+ FLAC__int32 v = (FLAC__int32)(val + 0.5);
+ if(!write_little_endian_int32(f, v))
+ goto foo;
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
+/* a stereo sine-wave 32bps stream */
+static FLAC__bool generate_sine32_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult)
+{
+ const FLAC__int32 full_scale = 0x7fffffff;
+ const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
+ const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
+ FILE *f;
+ double theta1, theta2;
+ unsigned i;
+
+ if(0 == (f = fopen(fn, "wb")))
+ return false;
+
+ for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
+ double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
+ FLAC__int32 v = (FLAC__int32)(val + 0.5);
+ if(!write_little_endian_int32(f, v))
+ goto foo;
+ val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale;
+ v = (FLAC__int32)(val + 0.5);
+ if(!write_little_endian_int32(f, v))
+ goto foo;
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
static FLAC__bool generate_noise(const char *fn, unsigned bytes)
{
FILE *f;
@@ -1176,6 +1257,14 @@ int main(int argc, char *argv[])
if(!generate_fsd24("fsd24-06.raw", pattern06, 100)) return 1;
if(!generate_fsd24("fsd24-07.raw", pattern07, 100)) return 1;
+ if(!generate_fsd32("fsd32-01.raw", pattern01, 100)) return 1;
+ if(!generate_fsd32("fsd32-02.raw", pattern02, 100)) return 1;
+ if(!generate_fsd32("fsd32-03.raw", pattern03, 100)) return 1;
+ if(!generate_fsd32("fsd32-04.raw", pattern04, 100)) return 1;
+ if(!generate_fsd32("fsd32-05.raw", pattern05, 100)) return 1;
+ if(!generate_fsd32("fsd32-06.raw", pattern06, 100)) return 1;
+ if(!generate_fsd32("fsd32-07.raw", pattern07, 100)) return 1;
+
if(!generate_wbps16("wbps16-01.raw", 1000)) return 1;
if(!generate_sine8_1("sine8-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
@@ -1229,6 +1318,23 @@ int main(int argc, char *argv[])
if(!generate_sine24_2("sine24-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
if(!generate_sine24_2("sine24-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
+ if(!generate_sine32_1("sine32-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
+ if(!generate_sine32_1("sine32-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
+ if(!generate_sine32_1("sine32-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
+ if(!generate_sine32_1("sine32-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
+ if(!generate_sine32_1("sine32-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
+
+ if(!generate_sine32_2("sine32-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
+ if(!generate_sine32_2("sine32-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
+ if(!generate_sine32_2("sine32-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
+ if(!generate_sine32_2("sine32-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
+ if(!generate_sine32_2("sine32-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
+ if(!generate_sine32_2("sine32-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
+ if(!generate_sine32_2("sine32-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
+ if(!generate_sine32_2("sine32-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
+ if(!generate_sine32_2("sine32-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
+ if(!generate_sine32_2("sine32-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
+
if(!generate_replaygain_tone(8000)) return 1;
if(!generate_replaygain_tone(11025)) return 1;
if(!generate_replaygain_tone(12000)) return 1;
diff --git a/test/test_streams.sh b/test/test_streams.sh
index bf05bf84..9755326a 100755
--- a/test/test_streams.sh
+++ b/test/test_streams.sh
@@ -184,7 +184,7 @@ test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
-for bps in 8 16 24 ; do
+for bps in 8 16 24 32 ; do
echo "Testing $bps-bit full-scale deflection streams..."
for b in 01 02 03 04 05 06 07 ; do
test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p"
@@ -196,7 +196,7 @@ for b in 01 ; do
test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
done
-for bps in 8 16 24 ; do
+for bps in 8 16 24 32; do
echo "Testing $bps-bit sine wave streams..."
for b in 00 ; do
test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
@@ -299,11 +299,11 @@ echo "Testing noise..."
for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
for channels in 1 2 4 8 ; do
- if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
- for bps in 8 16 24 ; do
+ if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
+ for bps in 8 16 24 32; do
for opt in 0 1 2 3 4 5 6 7 8 ; do
for extras in '' '-p' '-e' ; do
- if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
+ if { [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ]; } && { [ "$extras" != '-p' ] || [ "$opt" -gt 2 ]; } ; then
for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
test_file noise $channels $bps "-$opt $extras $blocksize $disable"