Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
803b73a3
Commit
803b73a3
authored
Apr 22, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmPack: add pcm_unpack_24be()
parent
b1512201
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
0 deletions
+38
-0
PcmPack.cxx
src/pcm/PcmPack.cxx
+9
-0
PcmPack.hxx
src/pcm/PcmPack.hxx
+7
-0
test_pcm_all.hxx
test/test_pcm_all.hxx
+2
-0
test_pcm_pack.cxx
test/test_pcm_pack.cxx
+20
-0
No files found.
src/pcm/PcmPack.cxx
View file @
803b73a3
...
...
@@ -94,3 +94,12 @@ pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end)
src
+=
3
;
}
}
void
pcm_unpack_24be
(
int32_t
*
dest
,
const
uint8_t
*
src
,
const
uint8_t
*
src_end
)
{
while
(
src
<
src_end
)
{
*
dest
++
=
ReadS24BE
(
src
);
src
+=
3
;
}
}
src/pcm/PcmPack.hxx
View file @
803b73a3
...
...
@@ -49,4 +49,11 @@ pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end);
void
pcm_unpack_24
(
int32_t
*
dest
,
const
uint8_t
*
src
,
const
uint8_t
*
src_end
);
/**
* Like pcm_unpack_24(), but assume the source byte order is
* big-endian. The destination byte order ia always native.
*/
void
pcm_unpack_24be
(
int32_t
*
dest
,
const
uint8_t
*
src
,
const
uint8_t
*
src_end
);
#endif
test/test_pcm_all.hxx
View file @
803b73a3
...
...
@@ -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
{
...
...
test/test_pcm_pack.cxx
View file @
803b73a3
...
...
@@ -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
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment