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
bf26adf5
Commit
bf26adf5
authored
Jun 18, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Dsd{16,32}: stash odd frames away for the next call
Similar to commit
32380d1d
, these are the final parts for really fixing
https://github.com/MusicPlayerDaemon/MPD/issues/469
parent
0cc94fe3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
21 deletions
+66
-21
Dsd16.cxx
src/pcm/Dsd16.cxx
+8
-10
Dsd16.hxx
src/pcm/Dsd16.hxx
+4
-0
Dsd32.cxx
src/pcm/Dsd32.cxx
+8
-11
Dsd32.hxx
src/pcm/Dsd32.hxx
+4
-0
test_pcm_export.cxx
test/test_pcm_export.cxx
+42
-0
No files found.
src/pcm/Dsd16.cxx
View file @
bf26adf5
...
...
@@ -20,6 +20,8 @@
#include "Dsd16.hxx"
#include "util/ConstBuffer.hxx"
#include <functional>
/**
* Construct a 16 bit integer from two bytes.
*/
...
...
@@ -54,18 +56,14 @@ void
Dsd16Converter
::
Open
(
unsigned
_channels
)
noexcept
{
channels
=
_channels
;
rest_buffer
.
Open
(
channels
);
}
ConstBuffer
<
uint16_t
>
Dsd16Converter
::
Convert
(
ConstBuffer
<
uint8_t
>
_
src
)
noexcept
Dsd16Converter
::
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
{
const
size_t
in_frames
=
_src
.
size
/
channels
;
const
size_t
out_frames
=
in_frames
/
2
;
const
size_t
out_samples
=
out_frames
*
channels
;
const
uint8_t
*
src
=
_src
.
data
;
const
auto
dest
=
buffer
.
GetT
<
uint16_t
>
(
out_samples
);
Dsd8To16
(
dest
,
src
,
out_frames
,
channels
);
return
{
dest
,
out_samples
};
using
namespace
std
::
placeholders
;
return
rest_buffer
.
Process
<
uint16_t
>
(
buffer
,
src
,
channels
,
std
::
bind
(
Dsd8To16
,
_1
,
_2
,
_3
,
channels
));
}
src/pcm/Dsd16.hxx
View file @
bf26adf5
...
...
@@ -21,6 +21,7 @@
#define MPD_PCM_DSD_16_HXX
#include "Buffer.hxx"
#include "RestBuffer.hxx"
#include <stdint.h>
...
...
@@ -34,10 +35,13 @@ class Dsd16Converter {
PcmBuffer
buffer
;
PcmRestBuffer
<
uint8_t
,
2
>
rest_buffer
;
public
:
void
Open
(
unsigned
_channels
)
noexcept
;
void
Reset
()
noexcept
{
rest_buffer
.
Reset
();
}
ConstBuffer
<
uint16_t
>
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
;
...
...
src/pcm/Dsd32.cxx
View file @
bf26adf5
...
...
@@ -18,9 +18,10 @@
*/
#include "Dsd32.hxx"
#include "Buffer.hxx"
#include "util/ConstBuffer.hxx"
#include <functional>
/**
* Construct a 32 bit integer from four bytes.
*/
...
...
@@ -57,18 +58,14 @@ void
Dsd32Converter
::
Open
(
unsigned
_channels
)
noexcept
{
channels
=
_channels
;
rest_buffer
.
Open
(
channels
);
}
ConstBuffer
<
uint32_t
>
Dsd32Converter
::
Convert
(
ConstBuffer
<
uint8_t
>
_
src
)
noexcept
Dsd32Converter
::
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
{
const
size_t
in_frames
=
_src
.
size
/
channels
;
const
size_t
out_frames
=
in_frames
/
4
;
const
size_t
out_samples
=
out_frames
*
channels
;
const
uint8_t
*
src
=
_src
.
data
;
const
auto
dest
=
buffer
.
GetT
<
uint32_t
>
(
out_samples
);
Dsd8To32
(
dest
,
src
,
out_frames
,
channels
);
return
{
dest
,
out_samples
};
using
namespace
std
::
placeholders
;
return
rest_buffer
.
Process
<
uint32_t
>
(
buffer
,
src
,
channels
,
std
::
bind
(
Dsd8To32
,
_1
,
_2
,
_3
,
channels
));
}
src/pcm/Dsd32.hxx
View file @
bf26adf5
...
...
@@ -21,6 +21,7 @@
#define MPD_PCM_DSD_32_HXX
#include "Buffer.hxx"
#include "RestBuffer.hxx"
#include <stdint.h>
...
...
@@ -34,10 +35,13 @@ class Dsd32Converter {
PcmBuffer
buffer
;
PcmRestBuffer
<
uint8_t
,
4
>
rest_buffer
;
public
:
void
Open
(
unsigned
_channels
)
noexcept
;
void
Reset
()
noexcept
{
rest_buffer
.
Reset
();
}
ConstBuffer
<
uint32_t
>
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
;
...
...
test/test_pcm_export.cxx
View file @
bf26adf5
...
...
@@ -152,6 +152,27 @@ TEST(PcmTest, ExportDsdU16)
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
EXPECT_EQ
(
sizeof
(
expected
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected
,
dest
.
size
)
==
0
);
/* no output, 2/4 remains */
static
constexpr
uint8_t
src2
[]
=
{
0x11
,
0x22
};
static
constexpr
uint16_t
expected2
[]
=
{};
dest
=
e
.
Export
({
src2
,
sizeof
(
src2
)});
EXPECT_EQ
(
sizeof
(
expected2
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected2
,
dest
.
size
)
==
0
);
/* one full frame and 2/4 remains */
static
constexpr
uint8_t
src3
[]
=
{
0x33
,
0x44
,
0x55
,
0x66
};
static
constexpr
uint16_t
expected3
[]
=
{
0x1133
,
0x2244
};
dest
=
e
.
Export
({
src3
,
sizeof
(
src3
)});
EXPECT_EQ
(
sizeof
(
expected3
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected3
,
dest
.
size
)
==
0
);
/* two full frames and 2/4 remains again */
static
constexpr
uint8_t
src4
[]
=
{
0x77
,
0x88
,
0x99
,
0xaa
,
0xbb
,
0xcc
,
0xdd
,
0xee
};
static
constexpr
uint16_t
expected4
[]
=
{
0x5577
,
0x6688
,
0x99bb
,
0xaacc
};
dest
=
e
.
Export
({
src4
,
sizeof
(
src4
)});
EXPECT_EQ
(
sizeof
(
expected4
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected4
,
dest
.
size
)
==
0
);
}
TEST
(
PcmTest
,
ExportDsdU32
)
...
...
@@ -182,6 +203,27 @@ TEST(PcmTest, ExportDsdU32)
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
EXPECT_EQ
(
sizeof
(
expected
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected
,
dest
.
size
)
==
0
);
/* no output, 4/8 remains */
static
constexpr
uint8_t
src2
[]
=
{
0x11
,
0x22
,
0x33
,
0x44
};
static
constexpr
uint32_t
expected2
[]
=
{};
dest
=
e
.
Export
({
src2
,
sizeof
(
src2
)});
EXPECT_EQ
(
sizeof
(
expected2
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected2
,
dest
.
size
)
==
0
);
/* one full frame and 4/8 remains */
static
constexpr
uint8_t
src3
[]
=
{
0x55
,
0x66
,
0x77
,
0x88
,
0x99
,
0xaa
,
0xbb
,
0xcc
};
static
constexpr
uint32_t
expected3
[]
=
{
0x11335577
,
0x22446688
};
dest
=
e
.
Export
({
src3
,
sizeof
(
src3
)});
EXPECT_EQ
(
sizeof
(
expected3
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected3
,
dest
.
size
)
==
0
);
/* two full frames and 2/4 remains again */
static
constexpr
uint8_t
src4
[]
=
{
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
};
static
constexpr
uint32_t
expected4
[]
=
{
0x99bb0103
,
0xaacc0204
};
dest
=
e
.
Export
({
src4
,
sizeof
(
src4
)});
EXPECT_EQ
(
sizeof
(
expected4
),
dest
.
size
);
EXPECT_TRUE
(
memcmp
(
dest
.
data
,
expected4
,
dest
.
size
)
==
0
);
}
TEST
(
PcmTest
,
ExportDop
)
...
...
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