pcm/PcmPack: add pcm_unpack_24be()

This commit is contained in:
Max Kellermann
2017-04-22 09:50:39 +02:00
parent b1512201ab
commit 803b73a34b
4 changed files with 38 additions and 0 deletions

View File

@@ -40,11 +40,13 @@ class PcmPackTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(PcmPackTest);
CPPUNIT_TEST(TestPack24);
CPPUNIT_TEST(TestUnpack24);
CPPUNIT_TEST(TestUnpack24BE);
CPPUNIT_TEST_SUITE_END();
public:
void TestPack24();
void TestUnpack24();
void TestUnpack24BE();
};
class PcmChannelsTest : public CppUnit::TestFixture {

View File

@@ -70,3 +70,23 @@ PcmPackTest::TestUnpack24()
CPPUNIT_ASSERT_EQUAL(s, dest[i]);
}
}
void
PcmPackTest::TestUnpack24BE()
{
constexpr unsigned N = 509;
const auto src = TestDataBuffer<uint8_t, N * 3>();
int32_t dest[N];
pcm_unpack_24be(dest, src.begin(), src.end());
for (unsigned i = 0; i < N; ++i) {
int32_t s;
s = (src[i * 3] << 16) | (src[i * 3 + 1] << 8)
| src[i * 3 + 2];
if (s & 0x800000)
s |= 0xff000000;
CPPUNIT_ASSERT_EQUAL(s, dest[i]);
}
}