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
424e9cbc
Commit
424e9cbc
authored
Apr 22, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/PcmPack: simplify unpack_sample()
parent
95b62a84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
PcmPack.cxx
src/pcm/PcmPack.cxx
+36
-13
No files found.
src/pcm/PcmPack.cxx
View file @
424e9cbc
...
...
@@ -45,22 +45,45 @@ pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end)
}
}
static
void
unpack_sample
(
int32_t
*
dest0
,
const
uint8_t
*
src
)
/**
* Construct a signed 24 bit integer from three bytes into a int32_t.
*/
static
constexpr
int32_t
ConstructS24
(
uint8_t
low
,
uint8_t
mid
,
uint8_t
high
)
{
uint8_t
*
dest
=
(
uint8_t
*
)
dest0
;
return
int32_t
(
low
)
|
(
int32_t
(
mid
)
<<
8
)
|
(
int32_t
(
high
)
<<
16
)
|
/* extend the sign bit */
(
high
&
0x80
?
~
int32_t
(
0xffffff
)
:
0
);
}
if
(
IsBigEndian
())
/* extend the sign bit to the most fourth byte */
*
dest
++
=
*
src
&
0x80
?
0xff
:
0x00
;
/**
* Read a packed signed little-endian 24 bit integer.
*/
gcc_pure
static
int32_t
ReadS24LE
(
const
uint8_t
*
src
)
{
return
ConstructS24
(
src
[
0
],
src
[
1
],
src
[
2
]);
}
*
dest
++
=
*
src
++
;
*
dest
++
=
*
src
++
;
*
dest
++
=
*
src
;
/**
* Read a packed signed big-endian 24 bit integer.
*/
gcc_pure
static
int32_t
ReadS24BE
(
const
uint8_t
*
src
)
{
return
ConstructS24
(
src
[
2
],
src
[
1
],
src
[
0
]);
}
if
(
IsLittleEndian
())
/* extend the sign bit to the most fourth byte */
*
dest
++
=
*
src
&
0x80
?
0xff
:
0x00
;
/**
* Read a packed signed native-endian 24 bit integer.
*/
gcc_pure
static
int32_t
ReadS24
(
const
uint8_t
*
src
)
{
return
IsBigEndian
()
?
ReadS24BE
(
src
)
:
ReadS24LE
(
src
);
}
void
...
...
@@ -70,7 +93,7 @@ pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end)
parameter to the unpack_sample() inline function) */
while
(
src
<
src_end
)
{
unpack_sample
(
dest
++
,
src
);
*
dest
++
=
ReadS24
(
src
);
src
+=
3
;
}
}
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