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
c6ef0e88
Commit
c6ef0e88
authored
Dec 02, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Traits: add typedef "sum_type"
Allow 32 bit platforms to use 32 bit instead of 64 bit for summing 24 bit samples.
parent
f761d583
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
PcmChannels.cxx
src/pcm/PcmChannels.cxx
+4
-4
PcmMix.cxx
src/pcm/PcmMix.cxx
+1
-1
Traits.hxx
src/pcm/Traits.hxx
+11
-0
No files found.
src/pcm/PcmChannels.cxx
View file @
c6ef0e88
...
...
@@ -44,8 +44,8 @@ static typename Traits::value_type
StereoToMono
(
typename
Traits
::
value_type
_a
,
typename
Traits
::
value_type
_b
)
{
typename
Traits
::
long
_type
a
(
_a
);
typename
Traits
::
long
_type
b
(
_b
);
typename
Traits
::
sum
_type
a
(
_a
);
typename
Traits
::
sum
_type
b
(
_b
);
return
typename
Traits
::
value_type
((
a
+
b
)
/
2
);
}
...
...
@@ -76,7 +76,7 @@ NToStereo(typename Traits::pointer_type dest,
assert
((
end
-
src
)
%
src_channels
==
0
);
while
(
src
!=
end
)
{
typename
Traits
::
long
_type
sum
=
*
src
++
;
typename
Traits
::
sum
_type
sum
=
*
src
++
;
for
(
unsigned
c
=
1
;
c
<
src_channels
;
++
c
)
sum
+=
*
src
++
;
...
...
@@ -101,7 +101,7 @@ NToM(typename Traits::pointer_type dest,
assert
((
end
-
src
)
%
src_channels
==
0
);
while
(
src
!=
end
)
{
typename
Traits
::
long
_type
sum
=
*
src
++
;
typename
Traits
::
sum
_type
sum
=
*
src
++
;
for
(
unsigned
c
=
1
;
c
<
src_channels
;
++
c
)
sum
+=
*
src
++
;
...
...
src/pcm/PcmMix.cxx
View file @
c6ef0e88
...
...
@@ -125,7 +125,7 @@ template<SampleFormat F, class Traits=SampleTraits<F>>
static
typename
Traits
::
value_type
PcmAdd
(
typename
Traits
::
value_type
_a
,
typename
Traits
::
value_type
_b
)
{
typename
Traits
::
long
_type
a
(
_a
),
b
(
_b
);
typename
Traits
::
sum
_type
a
(
_a
),
b
(
_b
);
return
PcmClamp
<
F
,
Traits
>
(
a
+
b
);
}
...
...
src/pcm/Traits.hxx
View file @
c6ef0e88
...
...
@@ -51,6 +51,13 @@ struct SampleTraits<SampleFormat::S8> {
typedef
const
value_type
*
const_pointer_type
;
/**
* A "long" type that is large and accurate enough for adding
* two values without risking an (integer) overflow or
* (floating point) precision loss.
*/
typedef
int
sum_type
;
/**
* A "long" type that is large and accurate enough for
* arithmetic without risking an (integer) overflow or
* (floating point) precision loss.
...
...
@@ -75,6 +82,7 @@ struct SampleTraits<SampleFormat::S16> {
typedef
value_type
*
pointer_type
;
typedef
const
value_type
*
const_pointer_type
;
typedef
int_least32_t
sum_type
;
typedef
int_least32_t
long_type
;
static
constexpr
size_t
SAMPLE_SIZE
=
sizeof
(
value_type
);
...
...
@@ -87,6 +95,7 @@ struct SampleTraits<SampleFormat::S32> {
typedef
value_type
*
pointer_type
;
typedef
const
value_type
*
const_pointer_type
;
typedef
int_least64_t
sum_type
;
typedef
int_least64_t
long_type
;
static
constexpr
size_t
SAMPLE_SIZE
=
sizeof
(
value_type
);
...
...
@@ -99,6 +108,7 @@ struct SampleTraits<SampleFormat::S24_P32> {
typedef
value_type
*
pointer_type
;
typedef
const
value_type
*
const_pointer_type
;
typedef
int_least32_t
sum_type
;
typedef
int_least64_t
long_type
;
static
constexpr
size_t
SAMPLE_SIZE
=
sizeof
(
value_type
);
...
...
@@ -111,6 +121,7 @@ struct SampleTraits<SampleFormat::FLOAT> {
typedef
value_type
*
pointer_type
;
typedef
const
value_type
*
const_pointer_type
;
typedef
float
sum_type
;
typedef
float
long_type
;
static
constexpr
size_t
SAMPLE_SIZE
=
sizeof
(
value_type
);
...
...
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