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
ef99d6ce
Commit
ef99d6ce
authored
Feb 01, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PcmUtils: remove pcm_range(), use PcmClamp() instead
parent
0ac06d77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
36 deletions
+12
-36
PcmMix.cxx
src/PcmMix.cxx
+8
-8
PcmUtils.hxx
src/PcmUtils.hxx
+0
-24
PcmVolume.cxx
src/PcmVolume.cxx
+4
-4
No files found.
src/PcmMix.cxx
View file @
ef99d6ce
...
...
@@ -37,7 +37,7 @@ pcm_add_vol_8(int8_t *buffer1, const int8_t *buffer2,
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer1
++
=
pcm_range
(
sample1
,
8
);
*
buffer1
++
=
PcmClamp
<
int8_t
,
int32_t
,
8
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -54,7 +54,7 @@ pcm_add_vol_16(int16_t *buffer1, const int16_t *buffer2,
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer1
++
=
pcm_range
(
sample1
,
16
);
*
buffer1
++
=
PcmClamp
<
int16_t
,
int32_t
,
16
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -71,7 +71,7 @@ pcm_add_vol_24(int32_t *buffer1, const int32_t *buffer2,
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer1
++
=
pcm_range
(
sample1
,
24
);
*
buffer1
++
=
PcmClamp
<
int32_t
,
int64_t
,
24
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -88,7 +88,7 @@ pcm_add_vol_32(int32_t *buffer1, const int32_t *buffer2,
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer1
++
=
pcm_range_64
(
sample1
,
32
);
*
buffer1
++
=
PcmClamp
<
int32_t
,
int64_t
,
32
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -160,7 +160,7 @@ pcm_add_8(int8_t *buffer1, const int8_t *buffer2, unsigned num_samples)
sample1
+=
sample2
;
*
buffer1
++
=
pcm_range
(
sample1
,
8
);
*
buffer1
++
=
PcmClamp
<
int8_t
,
int32_t
,
8
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -174,7 +174,7 @@ pcm_add_16(int16_t *buffer1, const int16_t *buffer2, unsigned num_samples)
sample1
+=
sample2
;
*
buffer1
++
=
pcm_range
(
sample1
,
16
);
*
buffer1
++
=
PcmClamp
<
int16_t
,
int32_t
,
16
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -188,7 +188,7 @@ pcm_add_24(int32_t *buffer1, const int32_t *buffer2, unsigned num_samples)
sample1
+=
sample2
;
*
buffer1
++
=
pcm_range
(
sample1
,
24
);
*
buffer1
++
=
PcmClamp
<
int32_t
,
int64_t
,
24
>
(
sample1
);
--
num_samples
;
}
}
...
...
@@ -202,7 +202,7 @@ pcm_add_32(int32_t *buffer1, const int32_t *buffer2, unsigned num_samples)
sample1
+=
sample2
;
*
buffer1
++
=
pcm_range_64
(
sample1
,
32
);
*
buffer1
++
=
PcmClamp
<
int32_t
,
int64_t
,
32
>
(
sample1
);
--
num_samples
;
}
}
...
...
src/PcmUtils.hxx
View file @
ef99d6ce
...
...
@@ -42,30 +42,6 @@ pcm_end_pointer(const T *p, size_t size)
* 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
(
gcc_unlikely
(
sample
<
(
-
1
<<
(
bits
-
1
))))
return
-
1
<<
(
bits
-
1
);
if
(
gcc_unlikely
(
sample
>=
(
1
<<
(
bits
-
1
))))
return
(
1
<<
(
bits
-
1
))
-
1
;
return
sample
;
}
/**
* Check if the value is within the range of the provided bit size,
* and caps it if necessary.
*/
static
inline
int64_t
pcm_range_64
(
int64_t
sample
,
unsigned
bits
)
{
if
(
gcc_unlikely
(
sample
<
((
int64_t
)
-
1
<<
(
bits
-
1
))))
return
(
int64_t
)
-
1
<<
(
bits
-
1
);
if
(
gcc_unlikely
(
sample
>=
((
int64_t
)
1
<<
(
bits
-
1
))))
return
((
int64_t
)
1
<<
(
bits
-
1
))
-
1
;
return
sample
;
}
template
<
typename
T
,
typename
U
,
unsigned
bits
>
gcc_const
static
inline
T
...
...
src/PcmVolume.cxx
View file @
ef99d6ce
...
...
@@ -40,7 +40,7 @@ pcm_volume_change_8(int8_t *buffer, const int8_t *end, int volume)
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range
(
sample
,
8
);
*
buffer
++
=
PcmClamp
<
int8_t
,
int16_t
,
8
>
(
sample
);
}
}
...
...
@@ -54,7 +54,7 @@ pcm_volume_change_16(int16_t *buffer, const int16_t *end, int volume)
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range
(
sample
,
16
);
*
buffer
++
=
PcmClamp
<
int16_t
,
int32_t
,
16
>
(
sample
);
}
}
...
...
@@ -107,7 +107,7 @@ pcm_volume_change_24(int32_t *buffer, const int32_t *end, int volume)
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
#endif
*
buffer
++
=
pcm_range
(
sample
,
24
);
*
buffer
++
=
PcmClamp
<
int32_t
,
int32_t
,
24
>
(
sample
);
}
}
...
...
@@ -127,7 +127,7 @@ pcm_volume_change_32(int32_t *buffer, const int32_t *end, int volume)
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range_64
(
sample
,
32
);
*
buffer
++
=
PcmClamp
<
int32_t
,
int64_t
,
32
>
(
sample
);
#endif
}
}
...
...
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