pcm/export: support DSD_U16

This commit is contained in:
Max Kellermann
2017-01-11 22:33:37 +01:00
parent a3c33000ee
commit 938affef32
7 changed files with 162 additions and 1 deletions

View File

@@ -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

View File

@@ -126,6 +126,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()
{