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
3a0f3eaa
Commit
3a0f3eaa
authored
Dec 02, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmUtils: use the SampleTraits library
parent
80eb8d9e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
17 deletions
+14
-17
PcmFormat.cxx
src/pcm/PcmFormat.cxx
+1
-3
PcmMix.cxx
src/pcm/PcmMix.cxx
+2
-6
PcmUtils.hxx
src/pcm/PcmUtils.hxx
+10
-5
PcmVolume.cxx
src/pcm/PcmVolume.cxx
+1
-3
No files found.
src/pcm/PcmFormat.cxx
View file @
3a0f3eaa
...
@@ -57,9 +57,7 @@ ConvertFromFloat(typename Traits::pointer_type dest,
...
@@ -57,9 +57,7 @@ ConvertFromFloat(typename Traits::pointer_type dest,
while
(
src
!=
end
)
{
while
(
src
!=
end
)
{
typename
Traits
::
long_type
sample
(
*
src
++
*
factor
);
typename
Traits
::
long_type
sample
(
*
src
++
*
factor
);
*
dest
++
=
PcmClamp
<
typename
Traits
::
value_type
,
*
dest
++
=
PcmClamp
<
F
,
Traits
>
(
sample
);
typename
Traits
::
long_type
,
Traits
::
BITS
>
(
sample
);
}
}
}
}
...
...
src/pcm/PcmMix.cxx
View file @
3a0f3eaa
...
@@ -38,9 +38,7 @@ PcmAddVolume(typename Traits::value_type _a, typename Traits::value_type _b,
...
@@ -38,9 +38,7 @@ PcmAddVolume(typename Traits::value_type _a, typename Traits::value_type _b,
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
return
PcmClamp
<
typename
Traits
::
value_type
,
return
PcmClamp
<
F
,
Traits
>
(
c
);
typename
Traits
::
long_type
,
Traits
::
BITS
>
(
c
);
}
}
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
...
@@ -129,9 +127,7 @@ PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b)
...
@@ -129,9 +127,7 @@ PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b)
{
{
typename
Traits
::
long_type
a
(
_a
),
b
(
_b
);
typename
Traits
::
long_type
a
(
_a
),
b
(
_b
);
return
PcmClamp
<
typename
Traits
::
value_type
,
return
PcmClamp
<
F
,
Traits
>
(
a
+
b
);
typename
Traits
::
long_type
,
Traits
::
BITS
>
(
a
+
b
);
}
}
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
...
...
src/pcm/PcmUtils.hxx
View file @
3a0f3eaa
...
@@ -26,6 +26,9 @@
...
@@ -26,6 +26,9 @@
#include <stdint.h>
#include <stdint.h>
enum
class
SampleFormat
:
uint8_t
;
template
<
SampleFormat
F
>
struct
SampleTraits
;
/**
/**
* Add a byte count to the specified pointer. This is a utility
* Add a byte count to the specified pointer. This is a utility
* function to convert a source pointer and a byte count to an "end"
* function to convert a source pointer and a byte count to an "end"
...
@@ -42,13 +45,15 @@ pcm_end_pointer(const T *p, size_t size)
...
@@ -42,13 +45,15 @@ pcm_end_pointer(const T *p, size_t size)
* Check if the value is within the range of the provided bit size,
* Check if the value is within the range of the provided bit size,
* and caps it if necessary.
* and caps it if necessary.
*/
*/
template
<
typename
T
,
typename
U
,
unsigned
bits
>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>
>
gcc_const
gcc_const
static
inline
T
static
inline
typename
Traits
::
value_type
PcmClamp
(
U
x
)
PcmClamp
(
typename
Traits
::
long_type
x
)
{
{
constexpr
U
MIN_VALUE
=
-
(
U
(
1
)
<<
(
bits
-
1
));
typedef
typename
Traits
::
value_type
T
;
constexpr
U
MAX_VALUE
=
(
U
(
1
)
<<
(
bits
-
1
))
-
1
;
typedef
typename
Traits
::
long_type
U
;
constexpr
U
MIN_VALUE
=
-
(
U
(
1
)
<<
(
Traits
::
BITS
-
1
));
constexpr
U
MAX_VALUE
=
(
U
(
1
)
<<
(
Traits
::
BITS
-
1
))
-
1
;
typedef
std
::
numeric_limits
<
T
>
limits
;
typedef
std
::
numeric_limits
<
T
>
limits
;
static_assert
(
MIN_VALUE
>=
limits
::
min
(),
"out of range"
);
static_assert
(
MIN_VALUE
>=
limits
::
min
(),
"out of range"
);
...
...
src/pcm/PcmVolume.cxx
View file @
3a0f3eaa
...
@@ -39,9 +39,7 @@ pcm_volume_change(typename Traits::pointer_type buffer,
...
@@ -39,9 +39,7 @@ pcm_volume_change(typename Traits::pointer_type buffer,
PCM_VOLUME_1
/
2
)
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
*
buffer
++
=
PcmClamp
<
typename
Traits
::
value_type
,
*
buffer
++
=
PcmClamp
<
F
,
Traits
>
(
sample
);
typename
Traits
::
long_type
,
Traits
::
BITS
>
(
sample
);
}
}
}
}
...
...
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