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
30c4136c
Commit
30c4136c
authored
Dec 02, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmVolume: use the SampleTraits library
parent
83e44750
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
30 deletions
+22
-30
PcmVolume.cxx
src/pcm/PcmVolume.cxx
+22
-30
No files found.
src/pcm/PcmVolume.cxx
View file @
30c4136c
...
...
@@ -20,37 +20,41 @@
#include "config.h"
#include "PcmVolume.hxx"
#include "PcmUtils.hxx"
#include "Traits.hxx"
#include "AudioFormat.hxx"
#include <stdint.h>
#include <string.h>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
void
pcm_volume_change_8
(
int8_t
*
buffer
,
const
int8_t
*
end
,
int
volume
)
pcm_volume_change
(
typename
Traits
::
pointer_type
buffer
,
typename
Traits
::
const_pointer_type
end
,
int
volume
)
{
while
(
buffer
<
end
)
{
int32_t
sample
=
*
buffer
;
typename
Traits
::
long_type
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer
++
=
PcmClamp
<
int8_t
,
int16_t
,
8
>
(
sample
);
*
buffer
++
=
PcmClamp
<
typename
Traits
::
value_type
,
typename
Traits
::
long_type
,
Traits
::
BITS
>
(
sample
);
}
}
static
void
pcm_volume_change_
16
(
int16_t
*
buffer
,
const
int16
_t
*
end
,
int
volume
)
pcm_volume_change_
8
(
int8_t
*
buffer
,
const
int8
_t
*
end
,
int
volume
)
{
while
(
buffer
<
end
)
{
int32_t
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
pcm_volume_change
<
SampleFormat
::
S8
>
(
buffer
,
end
,
volume
);
}
*
buffer
++
=
PcmClamp
<
int16_t
,
int32_t
,
16
>
(
sample
);
}
static
void
pcm_volume_change_16
(
int16_t
*
buffer
,
const
int16_t
*
end
,
int
volume
)
{
pcm_volume_change
<
SampleFormat
::
S16
>
(
buffer
,
end
,
volume
);
}
#ifdef __i386__
...
...
@@ -87,44 +91,32 @@ pcm_volume_sample_24(int32_t sample, int32_t volume, gcc_unused int32_t dither)
static
void
pcm_volume_change_24
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
{
while
(
buffer
<
end
)
{
#ifdef __i386__
while
(
buffer
<
end
)
{
/* assembly version for i386 */
int32_t
sample
=
*
buffer
;
sample
=
pcm_volume_sample_24
(
sample
,
volume
,
pcm_volume_dither
());
}
#else
/* portable version */
int64_t
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
pcm_volume_change
<
SampleFormat
::
S24_P32
>
(
buffer
,
end
,
volume
);
#endif
*
buffer
++
=
PcmClamp
<
int32_t
,
int32_t
,
24
>
(
sample
);
}
}
static
void
pcm_volume_change_32
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
{
while
(
buffer
<
end
)
{
#ifdef __i386__
while
(
buffer
<
end
)
{
/* assembly version for i386 */
int32_t
sample
=
*
buffer
;
*
buffer
++
=
pcm_volume_sample_24
(
sample
,
volume
,
0
);
}
#else
/* portable version */
int64_t
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer
++
=
PcmClamp
<
int32_t
,
int64_t
,
32
>
(
sample
);
pcm_volume_change
<
SampleFormat
::
S32
>
(
buffer
,
end
,
volume
);
#endif
}
}
static
void
...
...
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