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
5b5e46f5
Commit
5b5e46f5
authored
Sep 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_utils: added inline function pcm_dither()
Merge some code into an inline function, so we can optimize it later only once.
parent
75cba934
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
pcm_utils.c
src/pcm_utils.c
+10
-8
No files found.
src/pcm_utils.c
View file @
5b5e46f5
...
@@ -25,6 +25,12 @@
...
@@ -25,6 +25,12 @@
#include "audio_format.h"
#include "audio_format.h"
#include "os_compat.h"
#include "os_compat.h"
static
inline
int
pcm_dither
(
void
)
{
return
(
rand
()
&
511
)
-
(
rand
()
&
511
);
}
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
,
const
struct
audio_format
*
format
,
int
volume
)
int
volume
)
...
@@ -46,8 +52,7 @@ void pcm_volumeChange(char *buffer, int bufferSize,
...
@@ -46,8 +52,7 @@ void pcm_volumeChange(char *buffer, int bufferSize,
while
(
bufferSize
>
0
)
{
while
(
bufferSize
>
0
)
{
temp32
=
*
buffer16
;
temp32
=
*
buffer16
;
temp32
*=
volume
;
temp32
*=
volume
;
temp32
+=
rand
()
&
511
;
temp32
+=
pcm_dither
();
temp32
-=
rand
()
&
511
;
temp32
+=
500
;
temp32
+=
500
;
temp32
/=
1000
;
temp32
/=
1000
;
*
buffer16
=
temp32
>
32767
?
32767
:
*
buffer16
=
temp32
>
32767
?
32767
:
...
@@ -60,8 +65,7 @@ void pcm_volumeChange(char *buffer, int bufferSize,
...
@@ -60,8 +65,7 @@ void pcm_volumeChange(char *buffer, int bufferSize,
while
(
bufferSize
>
0
)
{
while
(
bufferSize
>
0
)
{
temp32
=
*
buffer8
;
temp32
=
*
buffer8
;
temp32
*=
volume
;
temp32
*=
volume
;
temp32
+=
rand
()
&
511
;
temp32
+=
pcm_dither
();
temp32
-=
rand
()
&
511
;
temp32
+=
500
;
temp32
+=
500
;
temp32
/=
1000
;
temp32
/=
1000
;
*
buffer8
=
temp32
>
127
?
127
:
*
buffer8
=
temp32
>
127
?
127
:
...
@@ -92,8 +96,7 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
...
@@ -92,8 +96,7 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
temp32
=
temp32
=
(
vol1
*
(
*
buffer16_1
)
+
(
vol1
*
(
*
buffer16_1
)
+
vol2
*
(
*
buffer16_2
));
vol2
*
(
*
buffer16_2
));
temp32
+=
rand
()
&
511
;
temp32
+=
pcm_dither
();
temp32
-=
rand
()
&
511
;
temp32
+=
500
;
temp32
+=
500
;
temp32
/=
1000
;
temp32
/=
1000
;
*
buffer16_1
=
*
buffer16_1
=
...
@@ -111,8 +114,7 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
...
@@ -111,8 +114,7 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
while
(
bufferSize1
>
0
&&
bufferSize2
>
0
)
{
while
(
bufferSize1
>
0
&&
bufferSize2
>
0
)
{
temp32
=
temp32
=
(
vol1
*
(
*
buffer8_1
)
+
vol2
*
(
*
buffer8_2
));
(
vol1
*
(
*
buffer8_1
)
+
vol2
*
(
*
buffer8_2
));
temp32
+=
rand
()
&
511
;
temp32
+=
pcm_dither
();
temp32
-=
rand
()
&
511
;
temp32
+=
500
;
temp32
+=
500
;
temp32
/=
1000
;
temp32
/=
1000
;
*
buffer8_1
=
*
buffer8_1
=
...
...
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