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
7eda72d4
Commit
7eda72d4
authored
Jan 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Volume: use number of samples instead of end pointer
parent
c75339ed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
25 deletions
+19
-25
Volume.cxx
src/pcm/Volume.cxx
+19
-25
No files found.
src/pcm/Volume.cxx
View file @
7eda72d4
...
@@ -48,57 +48,52 @@ static void
...
@@ -48,57 +48,52 @@ static void
pcm_volume_change
(
PcmDither
&
dither
,
pcm_volume_change
(
PcmDither
&
dither
,
typename
Traits
::
pointer_type
dest
,
typename
Traits
::
pointer_type
dest
,
typename
Traits
::
const_pointer_type
src
,
typename
Traits
::
const_pointer_type
src
,
typename
Traits
::
const_pointer_type
end
,
size_t
n
,
int
volume
)
int
volume
)
{
{
while
(
src
<
end
)
{
for
(
size_t
i
=
0
;
i
!=
n
;
++
i
)
const
auto
sample
=
*
src
++
;
dest
[
i
]
=
pcm_volume_sample
<
F
,
Traits
>
(
dither
,
src
[
i
],
volume
);
*
dest
++
=
pcm_volume_sample
<
F
,
Traits
>
(
dither
,
sample
,
volume
);
}
}
}
static
void
static
void
pcm_volume_change_8
(
PcmDither
&
dither
,
pcm_volume_change_8
(
PcmDither
&
dither
,
int8_t
*
dest
,
const
int8_t
*
src
,
const
int8_t
*
end
,
int8_t
*
dest
,
const
int8_t
*
src
,
size_t
n
,
int
volume
)
int
volume
)
{
{
pcm_volume_change
<
SampleFormat
::
S8
>
(
dither
,
dest
,
src
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S8
>
(
dither
,
dest
,
src
,
n
,
volume
);
}
}
static
void
static
void
pcm_volume_change_16
(
PcmDither
&
dither
,
pcm_volume_change_16
(
PcmDither
&
dither
,
int16_t
*
dest
,
const
int16_t
*
src
,
const
int16_t
*
end
,
int16_t
*
dest
,
const
int16_t
*
src
,
size_t
n
,
int
volume
)
int
volume
)
{
{
pcm_volume_change
<
SampleFormat
::
S16
>
(
dither
,
dest
,
src
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S16
>
(
dither
,
dest
,
src
,
n
,
volume
);
}
}
static
void
static
void
pcm_volume_change_24
(
PcmDither
&
dither
,
pcm_volume_change_24
(
PcmDither
&
dither
,
int32_t
*
dest
,
const
int32_t
*
src
,
const
int32_t
*
end
,
int32_t
*
dest
,
const
int32_t
*
src
,
size_t
n
,
int
volume
)
int
volume
)
{
{
pcm_volume_change
<
SampleFormat
::
S24_P32
>
(
dither
,
dest
,
src
,
end
,
pcm_volume_change
<
SampleFormat
::
S24_P32
>
(
dither
,
dest
,
src
,
n
,
volume
);
volume
);
}
}
static
void
static
void
pcm_volume_change_32
(
PcmDither
&
dither
,
pcm_volume_change_32
(
PcmDither
&
dither
,
int32_t
*
dest
,
const
int32_t
*
src
,
const
int32_t
*
end
,
int32_t
*
dest
,
const
int32_t
*
src
,
size_t
n
,
int
volume
)
int
volume
)
{
{
pcm_volume_change
<
SampleFormat
::
S32
>
(
dither
,
dest
,
src
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S32
>
(
dither
,
dest
,
src
,
n
,
volume
);
}
}
static
void
static
void
pcm_volume_change_float
(
float
*
dest
,
const
float
*
src
,
const
float
*
end
,
pcm_volume_change_float
(
float
*
dest
,
const
float
*
src
,
size_t
n
,
float
volume
)
float
volume
)
{
{
while
(
src
<
end
)
{
for
(
size_t
i
=
0
;
i
!=
n
;
++
i
)
float
sample
=
*
src
++
;
dest
[
i
]
=
src
[
i
]
*
volume
;
sample
*=
volume
;
*
dest
++
=
sample
;
}
}
}
bool
bool
...
@@ -142,7 +137,6 @@ PcmVolume::Apply(ConstBuffer<void> src)
...
@@ -142,7 +137,6 @@ PcmVolume::Apply(ConstBuffer<void> src)
return
{
data
,
src
.
size
};
return
{
data
,
src
.
size
};
}
}
const
void
*
end
=
pcm_end_pointer
(
src
.
data
,
src
.
size
);
switch
(
format
)
{
switch
(
format
)
{
case
SampleFormat
:
:
UNDEFINED
:
case
SampleFormat
:
:
UNDEFINED
:
case
SampleFormat
:
:
DSD
:
case
SampleFormat
:
:
DSD
:
...
@@ -152,35 +146,35 @@ PcmVolume::Apply(ConstBuffer<void> src)
...
@@ -152,35 +146,35 @@ PcmVolume::Apply(ConstBuffer<void> src)
case
SampleFormat
:
:
S8
:
case
SampleFormat
:
:
S8
:
pcm_volume_change_8
(
dither
,
(
int8_t
*
)
data
,
pcm_volume_change_8
(
dither
,
(
int8_t
*
)
data
,
(
const
int8_t
*
)
src
.
data
,
(
const
int8_t
*
)
src
.
data
,
(
const
int8_t
*
)
end
,
src
.
size
/
sizeof
(
int8_t
)
,
volume
);
volume
);
break
;
break
;
case
SampleFormat
:
:
S16
:
case
SampleFormat
:
:
S16
:
pcm_volume_change_16
(
dither
,
(
int16_t
*
)
data
,
pcm_volume_change_16
(
dither
,
(
int16_t
*
)
data
,
(
const
int16_t
*
)
src
.
data
,
(
const
int16_t
*
)
src
.
data
,
(
const
int16_t
*
)
end
,
src
.
size
/
sizeof
(
int16_t
)
,
volume
);
volume
);
break
;
break
;
case
SampleFormat
:
:
S24_P32
:
case
SampleFormat
:
:
S24_P32
:
pcm_volume_change_24
(
dither
,
(
int32_t
*
)
data
,
pcm_volume_change_24
(
dither
,
(
int32_t
*
)
data
,
(
const
int32_t
*
)
src
.
data
,
(
const
int32_t
*
)
src
.
data
,
(
const
int32_t
*
)
end
,
src
.
size
/
sizeof
(
int32_t
)
,
volume
);
volume
);
break
;
break
;
case
SampleFormat
:
:
S32
:
case
SampleFormat
:
:
S32
:
pcm_volume_change_32
(
dither
,
(
int32_t
*
)
data
,
pcm_volume_change_32
(
dither
,
(
int32_t
*
)
data
,
(
const
int32_t
*
)
src
.
data
,
(
const
int32_t
*
)
src
.
data
,
(
const
int32_t
*
)
end
,
src
.
size
/
sizeof
(
int32_t
)
,
volume
);
volume
);
break
;
break
;
case
SampleFormat
:
:
FLOAT
:
case
SampleFormat
:
:
FLOAT
:
pcm_volume_change_float
((
float
*
)
data
,
pcm_volume_change_float
((
float
*
)
data
,
(
const
float
*
)
src
.
data
,
(
const
float
*
)
src
.
data
,
(
const
float
*
)
end
,
src
.
size
/
sizeof
(
float
)
,
pcm_volume_to_float
(
volume
));
pcm_volume_to_float
(
volume
));
break
;
break
;
}
}
...
...
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