diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-11 22:33:37 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-11 22:47:12 +0100 |
commit | 938affef32bc6a2ae7b6bdaa8b22330ebb06d1cd (patch) | |
tree | ee87af2fb06cf2284b8003d63241a0a461df5b95 /test | |
parent | a3c33000ee545028eaa711a9c503a8fab89eb82f (diff) |
pcm/export: support DSD_U16
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pcm_all.hxx | 2 | ||||
-rw-r--r-- | test/test_pcm_export.cxx | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/test_pcm_all.hxx b/test/test_pcm_all.hxx index 8a5b83cb6..ace822ab8 100644 --- a/test/test_pcm_all.hxx +++ b/test/test_pcm_all.hxx @@ -128,6 +128,7 @@ class PcmExportTest : public CppUnit::TestFixture { CPPUNIT_TEST(TestPack24); CPPUNIT_TEST(TestReverseEndian); #ifdef ENABLE_DSD + CPPUNIT_TEST(TestDsdU16); CPPUNIT_TEST(TestDsdU32); CPPUNIT_TEST(TestDop); #endif @@ -139,6 +140,7 @@ public: void TestPack24(); void TestReverseEndian(); #ifdef ENABLE_DSD + void TestDsdU16(); void TestDsdU32(); void TestDop(); #endif diff --git a/test/test_pcm_export.cxx b/test/test_pcm_export.cxx index ba4ef347f..ebbeeaf57 100644 --- a/test/test_pcm_export.cxx +++ b/test/test_pcm_export.cxx @@ -127,6 +127,37 @@ PcmExportTest::TestReverseEndian() #ifdef ENABLE_DSD void +PcmExportTest::TestDsdU16() +{ + static constexpr uint8_t src[] = { + 0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0x11, 0x22, 0x33, 0x44, + 0x55, 0x66, 0x77, 0x88, + }; + + static constexpr uint16_t expected[] = { + 0x0145, 0x2367, + 0x89cd, 0xabef, + 0x1133, 0x2244, + 0x5577, 0x6688, + }; + + PcmExport::Params params; + params.dsd_u16 = true; + + CPPUNIT_ASSERT_EQUAL(params.CalcOutputSampleRate(705600u), 352800u); + CPPUNIT_ASSERT_EQUAL(params.CalcInputSampleRate(352800u), 705600u); + + PcmExport e; + e.Open(SampleFormat::DSD, 2, params); + + auto dest = e.Export({src, sizeof(src)}); + CPPUNIT_ASSERT_EQUAL(sizeof(expected), dest.size); + CPPUNIT_ASSERT(memcmp(dest.data, expected, dest.size) == 0); +} + +void PcmExportTest::TestDsdU32() { static constexpr uint8_t src[] = { |