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
69476b4f
Commit
69476b4f
authored
9 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Interleave: add optimization for 32 bit samples
Move code from the "vorbis" decoder.
parent
fdf92c5f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
8 deletions
+47
-8
VorbisDecoderPlugin.cxx
src/decoder/plugins/VorbisDecoderPlugin.cxx
+3
-7
Interleave.cxx
src/pcm/Interleave.cxx
+24
-1
Interleave.hxx
src/pcm/Interleave.hxx
+20
-0
No files found.
src/decoder/plugins/VorbisDecoderPlugin.cxx
View file @
69476b4f
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "../DecoderAPI.hxx"
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "input/InputStream.hxx"
#include "OggCodec.hxx"
#include "OggCodec.hxx"
#include "pcm/Interleave.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Macros.hxx"
#include "util/Macros.hxx"
#include "CheckAudioFormat.hxx"
#include "CheckAudioFormat.hxx"
...
@@ -181,13 +182,8 @@ static void
...
@@ -181,13 +182,8 @@ static void
vorbis_interleave
(
float
*
dest
,
const
float
*
const
*
src
,
vorbis_interleave
(
float
*
dest
,
const
float
*
const
*
src
,
unsigned
nframes
,
unsigned
channels
)
unsigned
nframes
,
unsigned
channels
)
{
{
for
(
const
float
*
const
*
src_end
=
src
+
channels
;
PcmInterleaveFloat
(
dest
,
ConstBuffer
<
const
float
*>
(
src
,
channels
),
src
!=
src_end
;
++
src
,
++
dest
)
{
nframes
);
float
*
gcc_restrict
d
=
dest
;
for
(
const
float
*
gcc_restrict
s
=
*
src
,
*
s_end
=
s
+
nframes
;
s
!=
s_end
;
++
s
,
d
+=
channels
)
*
d
=
*
s
;
}
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
src/pcm/Interleave.cxx
View file @
69476b4f
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "config.h"
#include "config.h"
#include "Interleave.hxx"
#include "Interleave.hxx"
#include <stdint.h>
#include <string.h>
#include <string.h>
static
void
static
void
...
@@ -38,12 +37,36 @@ GenericPcmInterleave(uint8_t *gcc_restrict dest,
...
@@ -38,12 +37,36 @@ GenericPcmInterleave(uint8_t *gcc_restrict dest,
}
}
void
void
PcmInterleave32
(
int32_t
*
gcc_restrict
dest
,
const
ConstBuffer
<
const
int32_t
*>
src
,
size_t
n_frames
)
{
for
(
const
auto
*
s
:
src
)
{
auto
*
d
=
dest
++
;
for
(
const
auto
*
const
s_end
=
s
+
n_frames
;
s
!=
s_end
;
++
s
,
d
+=
src
.
size
)
*
d
=
*
s
;
}
}
void
PcmInterleave
(
void
*
gcc_restrict
dest
,
PcmInterleave
(
void
*
gcc_restrict
dest
,
ConstBuffer
<
const
void
*>
src
,
ConstBuffer
<
const
void
*>
src
,
size_t
n_frames
,
size_t
sample_size
)
size_t
n_frames
,
size_t
sample_size
)
{
{
switch
(
sample_size
)
{
case
4
:
PcmInterleave32
((
int32_t
*
)
dest
,
ConstBuffer
<
const
int32_t
*>
((
const
int32_t
*
const
*
)
src
.
data
,
src
.
size
),
n_frames
);
break
;
default:
GenericPcmInterleave
((
uint8_t
*
)
dest
,
GenericPcmInterleave
((
uint8_t
*
)
dest
,
ConstBuffer
<
const
uint8_t
*>
((
const
uint8_t
*
const
*
)
src
.
data
,
ConstBuffer
<
const
uint8_t
*>
((
const
uint8_t
*
const
*
)
src
.
data
,
src
.
size
),
src
.
size
),
n_frames
,
sample_size
);
n_frames
,
sample_size
);
}
}
}
This diff is collapsed.
Click to expand it.
src/pcm/Interleave.hxx
View file @
69476b4f
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
#include "Compiler.h"
#include "Compiler.h"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include <stdint.h>
/**
/**
* Interleave planar PCM samples from #src to #dest.
* Interleave planar PCM samples from #src to #dest.
*/
*/
...
@@ -31,4 +33,22 @@ void
...
@@ -31,4 +33,22 @@ void
PcmInterleave
(
void
*
gcc_restrict
dest
,
ConstBuffer
<
const
void
*>
src
,
PcmInterleave
(
void
*
gcc_restrict
dest
,
ConstBuffer
<
const
void
*>
src
,
size_t
n_frames
,
size_t
sample_size
);
size_t
n_frames
,
size_t
sample_size
);
/**
* A variant of PcmInterleave() that assumes 32 bit samples (4 bytes
* per sample).
*/
void
PcmInterleave32
(
int32_t
*
gcc_restrict
dest
,
ConstBuffer
<
const
int32_t
*>
src
,
size_t
n_frames
);
static
inline
void
PcmInterleaveFloat
(
float
*
gcc_restrict
dest
,
ConstBuffer
<
const
float
*>
src
,
size_t
n_frames
)
{
PcmInterleave32
((
int32_t
*
)
dest
,
ConstBuffer
<
const
int32_t
*>
((
const
int32_t
*
const
*
)
src
.
data
,
src
.
size
),
n_frames
);
}
#endif
#endif
This diff is collapsed.
Click to expand it.
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