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
cee1ac15
Commit
cee1ac15
authored
Dec 02, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmChannels: implement fake N-to-M mapping
This is really just a mono mapper, but the important part is that this library cannot fail anymore.
parent
71b47ae3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
PcmChannels.cxx
src/pcm/PcmChannels.cxx
+27
-1
No files found.
src/pcm/PcmChannels.cxx
View file @
cee1ac15
...
...
@@ -91,6 +91,31 @@ NToStereo(typename Traits::pointer_type dest,
}
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
typename
Traits
::
pointer_type
NToM
(
typename
Traits
::
pointer_type
dest
,
unsigned
dest_channels
,
unsigned
src_channels
,
typename
Traits
::
const_pointer_type
src
,
typename
Traits
::
const_pointer_type
end
)
{
assert
((
end
-
src
)
%
src_channels
==
0
);
while
(
src
!=
end
)
{
typename
Traits
::
long_type
sum
=
*
src
++
;
for
(
unsigned
c
=
1
;
c
<
src_channels
;
++
c
)
sum
+=
*
src
++
;
typename
Traits
::
value_type
value
(
sum
/
int
(
src_channels
));
/* TODO: this is actually only mono ... */
for
(
unsigned
c
=
0
;
c
<
dest_channels
;
++
c
)
*
dest
++
=
value
;
}
return
dest
;
}
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
ConstBuffer
<
typename
Traits
::
value_type
>
ConvertChannels
(
PcmBuffer
&
buffer
,
unsigned
dest_channels
,
...
...
@@ -109,7 +134,8 @@ ConvertChannels(PcmBuffer &buffer,
else
if
(
dest_channels
==
2
)
NToStereo
<
F
>
(
dest
,
src_channels
,
src
.
begin
(),
src
.
end
());
else
return
nullptr
;
NToM
<
F
>
(
dest
,
dest_channels
,
src_channels
,
src
.
begin
(),
src
.
end
());
return
{
dest
,
dest_size
};
}
...
...
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