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
fb4f02cd
Commit
fb4f02cd
authored
Feb 26, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmExport: add flag to export to DSD_U32
parent
d1be643c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
PcmExport.cxx
src/pcm/PcmExport.cxx
+17
-0
PcmExport.hxx
src/pcm/PcmExport.hxx
+6
-0
test_pcm_all.hxx
test/test_pcm_all.hxx
+2
-0
test_pcm_export.cxx
test/test_pcm_export.cxx
+24
-0
No files found.
src/pcm/PcmExport.cxx
View file @
fb4f02cd
...
...
@@ -25,6 +25,7 @@
#include "util/ConstBuffer.hxx"
#ifdef ENABLE_DSD
#include "PcmDsd.hxx"
#include "PcmDop.hxx"
#endif
...
...
@@ -42,7 +43,15 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
:
SampleFormat
::
UNDEFINED
;
#ifdef ENABLE_DSD
assert
(
!
params
.
dsd_u32
||
!
params
.
dop
);
assert
(
!
params
.
dop
||
audio_valid_channel_count
(
_channels
));
dsd_u32
=
params
.
dsd_u32
&&
sample_format
==
SampleFormat
::
DSD
;
if
(
dsd_u32
)
/* after the conversion to DSD_U32, the DSD samples
are stuffed inside fake 32 bit samples */
sample_format
=
SampleFormat
::
S32
;
dop
=
params
.
dop
&&
sample_format
==
SampleFormat
::
DSD
;
if
(
dop
)
/* after the conversion to DoP, the DSD
...
...
@@ -77,6 +86,9 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const
return
audio_format
.
channels
*
3
;
#ifdef ENABLE_DSD
if
(
dsd_u32
)
return
channels
*
4
;
if
(
dop
)
/* the DSD-over-USB draft says that DSD 1-bit samples
are enclosed within 24 bit samples, and MPD's
...
...
@@ -96,6 +108,11 @@ PcmExport::Export(ConstBuffer<void> data)
alsa_channel_order
,
channels
);
#ifdef ENABLE_DSD
if
(
dsd_u32
)
data
=
Dsd8To32
(
dop_buffer
,
channels
,
ConstBuffer
<
uint8_t
>::
FromVoid
(
data
))
.
ToVoid
();
if
(
dop
)
data
=
pcm_dsd_to_dop
(
dop_buffer
,
channels
,
ConstBuffer
<
uint8_t
>::
FromVoid
(
data
))
...
...
src/pcm/PcmExport.hxx
View file @
fb4f02cd
...
...
@@ -35,6 +35,7 @@ template<typename T> struct ConstBuffer;
struct
PcmExport
{
struct
Params
{
bool
alsa_channel_order
=
false
;
bool
dsd_u32
=
false
;
bool
dop
=
false
;
bool
shift8
=
false
;
bool
pack24
=
false
;
...
...
@@ -89,6 +90,11 @@ struct PcmExport {
#ifdef ENABLE_DSD
/**
* Convert DSD (U8) to DSD_U32?
*/
bool
dsd_u32
;
/**
* Convert DSD to DSD-over-PCM (DoP)? Input format must be
* SampleFormat::DSD and output format must be
* SampleFormat::S24_P32.
...
...
test/test_pcm_all.hxx
View file @
fb4f02cd
...
...
@@ -125,6 +125,7 @@ class PcmExportTest : public CppUnit::TestFixture {
CPPUNIT_TEST
(
TestShift8
);
CPPUNIT_TEST
(
TestPack24
);
CPPUNIT_TEST
(
TestReverseEndian
);
CPPUNIT_TEST
(
TestDsdU32
);
CPPUNIT_TEST
(
TestDop
);
CPPUNIT_TEST
(
TestAlsaChannelOrder
);
CPPUNIT_TEST_SUITE_END
();
...
...
@@ -133,6 +134,7 @@ public:
void
TestShift8
();
void
TestPack24
();
void
TestReverseEndian
();
void
TestDsdU32
();
void
TestDop
();
void
TestAlsaChannelOrder
();
};
...
...
test/test_pcm_export.cxx
View file @
fb4f02cd
...
...
@@ -116,6 +116,30 @@ PcmExportTest::TestReverseEndian()
}
void
PcmExportTest
::
TestDsdU32
()
{
static
constexpr
uint8_t
src
[]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
,
};
static
constexpr
uint32_t
expected
[]
=
{
0xcd894501
,
0xefab6723
,
};
PcmExport
::
Params
params
;
params
.
dsd_u32
=
true
;
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
::
TestDop
()
{
static
constexpr
uint8_t
src
[]
=
{
...
...
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