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
d0193430
Commit
d0193430
authored
Oct 20, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_volume: pass an "end" pointer instead of a sample count
parent
e977ec92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
pcm_volume.c
src/pcm_volume.c
+13
-20
No files found.
src/pcm_volume.c
View file @
d0193430
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
#define G_LOG_DOMAIN "pcm_volume"
#define G_LOG_DOMAIN "pcm_volume"
static
void
static
void
pcm_volume_change_8
(
int8_t
*
buffer
,
unsigned
num_samples
,
int
volume
)
pcm_volume_change_8
(
int8_t
*
buffer
,
const
int8_t
*
end
,
int
volume
)
{
{
while
(
num_samples
>
0
)
{
while
(
buffer
<
end
)
{
int32_t
sample
=
*
buffer
;
int32_t
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
...
@@ -41,14 +41,13 @@ pcm_volume_change_8(int8_t *buffer, unsigned num_samples, int volume)
...
@@ -41,14 +41,13 @@ pcm_volume_change_8(int8_t *buffer, unsigned num_samples, int volume)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range
(
sample
,
8
);
*
buffer
++
=
pcm_range
(
sample
,
8
);
--
num_samples
;
}
}
}
}
static
void
static
void
pcm_volume_change_16
(
int16_t
*
buffer
,
unsigned
num_samples
,
int
volume
)
pcm_volume_change_16
(
int16_t
*
buffer
,
const
int16_t
*
end
,
int
volume
)
{
{
while
(
num_samples
>
0
)
{
while
(
buffer
<
end
)
{
int32_t
sample
=
*
buffer
;
int32_t
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
...
@@ -56,7 +55,6 @@ pcm_volume_change_16(int16_t *buffer, unsigned num_samples, int volume)
...
@@ -56,7 +55,6 @@ pcm_volume_change_16(int16_t *buffer, unsigned num_samples, int volume)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range
(
sample
,
16
);
*
buffer
++
=
pcm_range
(
sample
,
16
);
--
num_samples
;
}
}
}
}
...
@@ -92,9 +90,9 @@ pcm_volume_sample_24(int32_t sample, int32_t volume, G_GNUC_UNUSED int32_t dithe
...
@@ -92,9 +90,9 @@ pcm_volume_sample_24(int32_t sample, int32_t volume, G_GNUC_UNUSED int32_t dithe
#endif
#endif
static
void
static
void
pcm_volume_change_24
(
int32_t
*
buffer
,
unsigned
num_samples
,
int
volume
)
pcm_volume_change_24
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
{
{
while
(
num_samples
>
0
)
{
while
(
buffer
<
end
)
{
#ifdef __i386__
#ifdef __i386__
/* assembly version for i386 */
/* assembly version for i386 */
int32_t
sample
=
*
buffer
;
int32_t
sample
=
*
buffer
;
...
@@ -110,14 +108,13 @@ pcm_volume_change_24(int32_t *buffer, unsigned num_samples, int volume)
...
@@ -110,14 +108,13 @@ pcm_volume_change_24(int32_t *buffer, unsigned num_samples, int volume)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
#endif
#endif
*
buffer
++
=
pcm_range
(
sample
,
24
);
*
buffer
++
=
pcm_range
(
sample
,
24
);
--
num_samples
;
}
}
}
}
static
void
static
void
pcm_volume_change_32
(
int32_t
*
buffer
,
unsigned
num_samples
,
int
volume
)
pcm_volume_change_32
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
{
{
while
(
num_samples
>
0
)
{
while
(
buffer
<
end
)
{
#ifdef __i386__
#ifdef __i386__
/* assembly version for i386 */
/* assembly version for i386 */
int32_t
sample
=
*
buffer
;
int32_t
sample
=
*
buffer
;
...
@@ -132,8 +129,6 @@ pcm_volume_change_32(int32_t *buffer, unsigned num_samples, int volume)
...
@@ -132,8 +129,6 @@ pcm_volume_change_32(int32_t *buffer, unsigned num_samples, int volume)
/
PCM_VOLUME_1
;
/
PCM_VOLUME_1
;
*
buffer
++
=
pcm_range_64
(
sample
,
32
);
*
buffer
++
=
pcm_range_64
(
sample
,
32
);
#endif
#endif
--
num_samples
;
}
}
}
}
...
@@ -150,6 +145,7 @@ pcm_volume(void *buffer, size_t length,
...
@@ -150,6 +145,7 @@ pcm_volume(void *buffer, size_t length,
return
true
;
return
true
;
}
}
const
void
*
end
=
pcm_end_pointer
(
buffer
,
length
);
switch
(
format
)
{
switch
(
format
)
{
case
SAMPLE_FORMAT_UNDEFINED
:
case
SAMPLE_FORMAT_UNDEFINED
:
case
SAMPLE_FORMAT_S24
:
case
SAMPLE_FORMAT_S24
:
...
@@ -157,22 +153,19 @@ pcm_volume(void *buffer, size_t length,
...
@@ -157,22 +153,19 @@ pcm_volume(void *buffer, size_t length,
return
false
;
return
false
;
case
SAMPLE_FORMAT_S8
:
case
SAMPLE_FORMAT_S8
:
pcm_volume_change_8
(
(
int8_t
*
)
buffer
,
length
,
volume
);
pcm_volume_change_8
(
buffer
,
end
,
volume
);
return
true
;
return
true
;
case
SAMPLE_FORMAT_S16
:
case
SAMPLE_FORMAT_S16
:
pcm_volume_change_16
((
int16_t
*
)
buffer
,
length
/
2
,
pcm_volume_change_16
(
buffer
,
end
,
volume
);
volume
);
return
true
;
return
true
;
case
SAMPLE_FORMAT_S24_P32
:
case
SAMPLE_FORMAT_S24_P32
:
pcm_volume_change_24
((
int32_t
*
)
buffer
,
length
/
4
,
pcm_volume_change_24
(
buffer
,
end
,
volume
);
volume
);
return
true
;
return
true
;
case
SAMPLE_FORMAT_S32
:
case
SAMPLE_FORMAT_S32
:
pcm_volume_change_32
((
int32_t
*
)
buffer
,
length
/
4
,
pcm_volume_change_32
(
buffer
,
end
,
volume
);
volume
);
return
true
;
return
true
;
}
}
...
...
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