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
e8c323ed
Commit
e8c323ed
authored
Jan 07, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_utils: export pcm_range()
We are going to split the pcm_utils.c library, and pcm_range() will be useful for several sub libraries.
parent
9cb76856
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
pcm_utils.c
src/pcm_utils.c
+0
-14
pcm_utils.h
src/pcm_utils.h
+16
-0
No files found.
src/pcm_utils.c
View file @
e8c323ed
...
...
@@ -41,20 +41,6 @@ pcm_dither(void)
return
(
r
&
511
)
-
((
r
>>
9
)
&
511
);
}
/**
* Check if the value is within the range of the provided bit size,
* and caps it if necessary.
*/
static
int32_t
pcm_range
(
int32_t
sample
,
unsigned
bits
)
{
if
(
G_UNLIKELY
(
sample
<
(
-
1
<<
(
bits
-
1
))))
return
-
1
<<
(
bits
-
1
);
if
(
G_UNLIKELY
(
sample
>=
(
1
<<
(
bits
-
1
))))
return
(
1
<<
(
bits
-
1
))
-
1
;
return
sample
;
}
static
void
pcm_volume_change_8
(
int8_t
*
buffer
,
unsigned
num_samples
,
int
volume
)
{
...
...
src/pcm_utils.h
View file @
e8c323ed
...
...
@@ -22,6 +22,8 @@
#include "pcm_resample.h"
#include "pcm_dither.h"
#include <glib.h>
#include <stdint.h>
#include <stddef.h>
...
...
@@ -42,6 +44,20 @@ struct pcm_convert_state {
};
/**
* Check if the value is within the range of the provided bit size,
* and caps it if necessary.
*/
static
inline
int32_t
pcm_range
(
int32_t
sample
,
unsigned
bits
)
{
if
(
G_UNLIKELY
(
sample
<
(
-
1
<<
(
bits
-
1
))))
return
-
1
<<
(
bits
-
1
);
if
(
G_UNLIKELY
(
sample
>=
(
1
<<
(
bits
-
1
))))
return
(
1
<<
(
bits
-
1
))
-
1
;
return
sample
;
}
/**
* Converts a float value (0.0 = silence, 1.0 = 100% volume) to an
* integer volume value (1000 = 100%).
*/
...
...
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