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
3165e26f
Commit
3165e26f
authored
Mar 02, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_format: added conversion from 32 bit
Support converting 32 bit samples to any other supported sample format.
parent
d4e4c57b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
pcm_format.c
src/pcm_format.c
+37
-0
No files found.
src/pcm_format.c
View file @
3165e26f
...
...
@@ -40,6 +40,14 @@ pcm_convert_24_to_16(struct pcm_dither *dither,
pcm_dither_24_to_16
(
dither
,
out
,
in
,
num_samples
);
}
static
void
pcm_convert_32_to_16
(
struct
pcm_dither
*
dither
,
int16_t
*
out
,
const
int32_t
*
in
,
unsigned
num_samples
)
{
pcm_dither_32_to_16
(
dither
,
out
,
in
,
num_samples
);
}
const
int16_t
*
pcm_convert_to_16
(
struct
pcm_buffer
*
buffer
,
struct
pcm_dither
*
dither
,
uint8_t
bits
,
const
void
*
src
,
...
...
@@ -72,6 +80,16 @@ pcm_convert_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
(
const
int32_t
*
)
src
,
num_samples
);
return
dest
;
case
32
:
num_samples
=
src_size
/
4
;
*
dest_size_r
=
num_samples
*
sizeof
(
*
dest
);
dest
=
pcm_buffer_get
(
buffer
,
*
dest_size_r
);
pcm_convert_32_to_16
(
dither
,
dest
,
(
const
int32_t
*
)
src
,
num_samples
);
return
dest
;
}
g_warning
(
"only 8 or 16 bits are supported for conversion!
\n
"
);
...
...
@@ -98,6 +116,16 @@ pcm_convert_16_to_24(int32_t *out, const int16_t *in,
}
}
static
void
pcm_convert_32_to_24
(
int32_t
*
out
,
const
int16_t
*
in
,
unsigned
num_samples
)
{
while
(
num_samples
>
0
)
{
*
out
++
=
*
in
++
>>
8
;
--
num_samples
;
}
}
const
int32_t
*
pcm_convert_to_24
(
struct
pcm_buffer
*
buffer
,
uint8_t
bits
,
const
void
*
src
,
...
...
@@ -128,6 +156,15 @@ pcm_convert_to_24(struct pcm_buffer *buffer,
case
24
:
*
dest_size_r
=
src_size
;
return
src
;
case
32
:
num_samples
=
src_size
/
4
;
*
dest_size_r
=
num_samples
*
sizeof
(
*
dest
);
dest
=
pcm_buffer_get
(
buffer
,
*
dest_size_r
);
pcm_convert_32_to_24
(
dest
,
(
const
int16_t
*
)
src
,
num_samples
);
return
dest
;
}
g_warning
(
"only 8 or 24 bits are supported for conversion!
\n
"
);
...
...
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