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
ead7ae85
Commit
ead7ae85
authored
Dec 09, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/wavpack: use template for format_sample_X()
parent
ad5abba8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
20 deletions
+7
-20
WavpackDecoderPlugin.cxx
src/decoder/plugins/WavpackDecoderPlugin.cxx
+7
-20
No files found.
src/decoder/plugins/WavpackDecoderPlugin.cxx
View file @
ead7ae85
...
...
@@ -71,13 +71,14 @@ GetDuration(WavpackContext *wpc)
}
/*
* Convert
8 bit
.
* Convert
integer samples
.
*/
template
<
typename
T
>
static
void
format_samples_
8
(
void
*
buffer
,
uint32_t
count
)
format_samples_
int
(
void
*
buffer
,
uint32_t
count
)
{
int32_t
*
src
=
(
int32_t
*
)
buffer
;
int8_t
*
dst
=
(
int8_t
*
)
buffer
;
T
*
dst
=
(
T
*
)
buffer
;
/*
* The asserts like the following one are because we do the
* formatting of samples within a single buffer. The size of
...
...
@@ -86,21 +87,7 @@ format_samples_8(void *buffer, uint32_t count)
*/
static_assert
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
),
"Wrong size"
);
/* pass through and align 8-bit samples */
std
::
copy_n
(
src
,
count
,
dst
);
}
/*
* Convert 16 bit.
*/
static
void
format_samples_16
(
void
*
buffer
,
uint32_t
count
)
{
int32_t
*
src
=
(
int32_t
*
)
buffer
;
int16_t
*
dst
=
(
int16_t
*
)
buffer
;
static_assert
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
),
"Wrong size"
);
/* pass through and align 16-bit samples */
/* pass through and align samples */
std
::
copy_n
(
src
,
count
,
dst
);
}
...
...
@@ -160,11 +147,11 @@ wavpack_decode(DecoderClient &client, WavpackContext *wpc, bool can_seek)
if
(
!
is_float
)
{
switch
(
WavpackGetBytesPerSample
(
wpc
))
{
case
1
:
format_samples
=
format_samples_
8
;
format_samples
=
format_samples_
int
<
int8_t
>
;
break
;
case
2
:
format_samples
=
format_samples_
16
;
format_samples
=
format_samples_
int
<
int16_t
>
;
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