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
e6a91d29
Commit
e6a91d29
authored
Jan 31, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PcmChannels: merge duplicate code with a template
parent
bf359727
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
38 deletions
+9
-38
PcmChannels.cxx
src/PcmChannels.cxx
+9
-38
No files found.
src/PcmChannels.cxx
View file @
e6a91d29
...
...
@@ -24,17 +24,17 @@
#include <assert.h>
template
<
typename
D
,
typename
S
>
static
void
pcm_convert_channels_16_1_to_2
(
int16_t
*
restrict
dest
,
const
int16_t
*
restrict
src
,
const
int16_t
*
restrict
src_end
)
MonoToStereo
(
D
dest
,
S
src
,
S
end
)
{
while
(
src
<
src_
end
)
{
int16_t
value
=
*
src
++
;
while
(
src
!=
end
)
{
const
auto
value
=
*
src
++
;
*
dest
++
=
value
;
*
dest
++
=
value
;
}
}
static
void
...
...
@@ -88,7 +88,7 @@ pcm_convert_channels_16(struct pcm_buffer *buffer,
const
int16_t
*
src_end
=
pcm_end_pointer
(
src
,
src_size
);
if
(
src_channels
==
1
&&
dest_channels
==
2
)
pcm_convert_channels_16_1_to_2
(
dest
,
src
,
src_end
);
MonoToStereo
(
dest
,
src
,
src_end
);
else
if
(
src_channels
==
2
&&
dest_channels
==
1
)
pcm_convert_channels_16_2_to_1
(
dest
,
src
,
src_end
);
else
if
(
dest_channels
==
2
)
...
...
@@ -101,19 +101,6 @@ pcm_convert_channels_16(struct pcm_buffer *buffer,
}
static
void
pcm_convert_channels_24_1_to_2
(
int32_t
*
restrict
dest
,
const
int32_t
*
restrict
src
,
const
int32_t
*
restrict
src_end
)
{
while
(
src
<
src_end
)
{
int32_t
value
=
*
src
++
;
*
dest
++
=
value
;
*
dest
++
=
value
;
}
}
static
void
pcm_convert_channels_24_2_to_1
(
int32_t
*
restrict
dest
,
const
int32_t
*
restrict
src
,
const
int32_t
*
restrict
src_end
)
...
...
@@ -165,7 +152,7 @@ pcm_convert_channels_24(struct pcm_buffer *buffer,
pcm_end_pointer
(
src
,
src_size
);
if
(
src_channels
==
1
&&
dest_channels
==
2
)
pcm_convert_channels_24_1_to_2
(
dest
,
src
,
src_end
);
MonoToStereo
(
dest
,
src
,
src_end
);
else
if
(
src_channels
==
2
&&
dest_channels
==
1
)
pcm_convert_channels_24_2_to_1
(
dest
,
src
,
src_end
);
else
if
(
dest_channels
==
2
)
...
...
@@ -178,13 +165,6 @@ pcm_convert_channels_24(struct pcm_buffer *buffer,
}
static
void
pcm_convert_channels_32_1_to_2
(
int32_t
*
dest
,
const
int32_t
*
src
,
const
int32_t
*
src_end
)
{
pcm_convert_channels_24_1_to_2
(
dest
,
src
,
src_end
);
}
static
void
pcm_convert_channels_32_2_to_1
(
int32_t
*
restrict
dest
,
const
int32_t
*
restrict
src
,
const
int32_t
*
restrict
src_end
)
...
...
@@ -235,7 +215,7 @@ pcm_convert_channels_32(struct pcm_buffer *buffer,
pcm_end_pointer
(
src
,
src_size
);
if
(
src_channels
==
1
&&
dest_channels
==
2
)
pcm_convert_channels_32_1_to_2
(
dest
,
src
,
src_end
);
MonoToStereo
(
dest
,
src
,
src_end
);
else
if
(
src_channels
==
2
&&
dest_channels
==
1
)
pcm_convert_channels_32_2_to_1
(
dest
,
src
,
src_end
);
else
if
(
dest_channels
==
2
)
...
...
@@ -248,15 +228,6 @@ pcm_convert_channels_32(struct pcm_buffer *buffer,
}
static
void
pcm_convert_channels_float_1_to_2
(
float
*
dest
,
const
float
*
src
,
const
float
*
src_end
)
{
pcm_convert_channels_24_1_to_2
((
int32_t
*
)
dest
,
(
const
int32_t
*
)
src
,
(
const
int32_t
*
)
src_end
);
}
static
void
pcm_convert_channels_float_2_to_1
(
float
*
restrict
dest
,
const
float
*
restrict
src
,
const
float
*
restrict
src_end
)
...
...
@@ -306,7 +277,7 @@ pcm_convert_channels_float(struct pcm_buffer *buffer,
const
float
*
src_end
=
(
const
float
*
)
pcm_end_pointer
(
src
,
src_size
);
if
(
src_channels
==
1
&&
dest_channels
==
2
)
pcm_convert_channels_float_1_to_2
(
dest
,
src
,
src_end
);
MonoToStereo
(
dest
,
src
,
src_end
);
else
if
(
src_channels
==
2
&&
dest_channels
==
1
)
pcm_convert_channels_float_2_to_1
(
dest
,
src
,
src_end
);
else
if
(
dest_channels
==
2
)
...
...
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