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
5b61e077
Commit
5b61e077
authored
Mar 21, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_export: add option "pack"
Converts padded 24 bit samples to packed 24 bit samples. Will replace the packed S24 sample format, which is not used internally.
parent
921cc3e5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
4 deletions
+39
-4
alsa_output_plugin.c
src/output/alsa_output_plugin.c
+1
-1
oss_output_plugin.c
src/output/oss_output_plugin.c
+1
-0
pcm_export.c
src/pcm_export.c
+24
-2
pcm_export.h
src/pcm_export.h
+13
-1
No files found.
src/output/alsa_output_plugin.c
View file @
5b61e077
...
@@ -525,7 +525,7 @@ configure_hw:
...
@@ -525,7 +525,7 @@ configure_hw:
ad
->
period_position
=
0
;
ad
->
period_position
=
0
;
pcm_export_open
(
&
ad
->
export
,
audio_format
->
format
,
pcm_export_open
(
&
ad
->
export
,
audio_format
->
format
,
reverse_endian
);
false
,
reverse_endian
);
return
true
;
return
true
;
...
...
src/output/oss_output_plugin.c
View file @
5b61e077
...
@@ -536,6 +536,7 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
...
@@ -536,6 +536,7 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
#ifdef AFMT_S24_PACKED
#ifdef AFMT_S24_PACKED
pcm_export_open
(
export
,
sample_format
,
pcm_export_open
(
export
,
sample_format
,
false
,
oss_format
==
AFMT_S24_PACKED
&&
oss_format
==
AFMT_S24_PACKED
&&
G_BYTE_ORDER
!=
G_LITTLE_ENDIAN
);
G_BYTE_ORDER
!=
G_LITTLE_ENDIAN
);
#endif
#endif
...
...
src/pcm_export.c
View file @
5b61e077
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "config.h"
#include "pcm_export.h"
#include "pcm_export.h"
#include "pcm_pack.h"
#include "util/byte_reverse.h"
#include "util/byte_reverse.h"
void
void
...
@@ -35,11 +36,15 @@ void pcm_export_deinit(struct pcm_export_state *state)
...
@@ -35,11 +36,15 @@ void pcm_export_deinit(struct pcm_export_state *state)
void
void
pcm_export_open
(
struct
pcm_export_state
*
state
,
pcm_export_open
(
struct
pcm_export_state
*
state
,
enum
sample_format
sample_format
,
enum
sample_format
sample_format
,
bool
reverse_endian
)
bool
pack
,
bool
reverse_endian
)
{
{
state
->
pack24
=
pack
&&
sample_format
==
SAMPLE_FORMAT_S24_P32
;
state
->
reverse_endian
=
0
;
state
->
reverse_endian
=
0
;
if
(
reverse_endian
)
{
if
(
reverse_endian
)
{
size_t
sample_size
=
sample_format_size
(
sample_format
);
size_t
sample_size
=
state
->
pack24
?
3
:
sample_format_size
(
sample_format
);
assert
(
sample_size
<=
0xff
);
assert
(
sample_size
<=
0xff
);
if
(
sample_size
>
1
)
if
(
sample_size
>
1
)
...
@@ -51,6 +56,23 @@ const void *
...
@@ -51,6 +56,23 @@ const void *
pcm_export
(
struct
pcm_export_state
*
state
,
const
void
*
data
,
size_t
size
,
pcm_export
(
struct
pcm_export_state
*
state
,
const
void
*
data
,
size_t
size
,
size_t
*
dest_size_r
)
size_t
*
dest_size_r
)
{
{
if
(
state
->
pack24
)
{
assert
(
size
%
4
==
0
);
const
size_t
num_samples
=
size
/
4
;
const
size_t
dest_size
=
num_samples
*
3
;
const
uint8_t
*
src8
=
data
,
*
src_end8
=
src8
+
size
;
uint8_t
*
dest
=
pcm_buffer_get
(
&
state
->
pack_buffer
,
dest_size
);
assert
(
dest
!=
NULL
);
pcm_pack_24
(
dest
,
(
const
int32_t
*
)
src8
,
(
const
int32_t
*
)
src_end8
);
data
=
dest
;
size
=
dest_size
;
}
if
(
state
->
reverse_endian
>
0
)
{
if
(
state
->
reverse_endian
>
0
)
{
assert
(
state
->
reverse_endian
>=
2
);
assert
(
state
->
reverse_endian
>=
2
);
...
...
src/pcm_export.h
View file @
5b61e077
...
@@ -35,6 +35,13 @@ struct audio_format;
...
@@ -35,6 +35,13 @@ struct audio_format;
*/
*/
struct
pcm_export_state
{
struct
pcm_export_state
{
/**
/**
* The buffer used to pack samples, removing padding.
*
* @see #reverse_endian
*/
struct
pcm_buffer
pack_buffer
;
/**
* The buffer used to reverse the byte order.
* The buffer used to reverse the byte order.
*
*
* @see #reverse_endian
* @see #reverse_endian
...
@@ -42,6 +49,11 @@ struct pcm_export_state {
...
@@ -42,6 +49,11 @@ struct pcm_export_state {
struct
pcm_buffer
reverse_buffer
;
struct
pcm_buffer
reverse_buffer
;
/**
/**
* Pack 24 bit samples?
*/
bool
pack24
;
/**
* Export the samples in reverse byte order? A non-zero value
* Export the samples in reverse byte order? A non-zero value
* means the option is enabled and represents the size of each
* means the option is enabled and represents the size of each
* sample (2 or bigger).
* sample (2 or bigger).
...
@@ -72,7 +84,7 @@ pcm_export_deinit(struct pcm_export_state *state);
...
@@ -72,7 +84,7 @@ pcm_export_deinit(struct pcm_export_state *state);
void
void
pcm_export_open
(
struct
pcm_export_state
*
state
,
pcm_export_open
(
struct
pcm_export_state
*
state
,
enum
sample_format
sample_format
,
enum
sample_format
sample_format
,
bool
reverse_endian
);
bool
pack
,
bool
reverse_endian
);
/**
/**
* Export a PCM buffer.
* Export a PCM buffer.
...
...
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