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
ece6037a
Commit
ece6037a
authored
Oct 10, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_byteswap: add function with sample_format overload
parent
bea678a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
pcm_byteswap.c
src/pcm_byteswap.c
+26
-0
pcm_byteswap.h
src/pcm_byteswap.h
+17
-0
No files found.
src/pcm_byteswap.c
View file @
ece6037a
...
...
@@ -68,3 +68,29 @@ const int32_t *pcm_byteswap_32(struct pcm_buffer *buffer,
return
buf
;
}
const
void
*
pcm_byteswap
(
struct
pcm_buffer
*
buffer
,
enum
sample_format
format
,
const
void
*
src
,
size_t
size
)
{
switch
(
format
)
{
case
SAMPLE_FORMAT_UNDEFINED
:
case
SAMPLE_FORMAT_S24
:
/* not implemented */
return
NULL
;
case
SAMPLE_FORMAT_S8
:
return
src
;
case
SAMPLE_FORMAT_S16
:
return
pcm_byteswap_16
(
buffer
,
src
,
size
);
case
SAMPLE_FORMAT_S24_P32
:
case
SAMPLE_FORMAT_S32
:
return
pcm_byteswap_32
(
buffer
,
src
,
size
);
}
/* unreachable */
assert
(
false
);
return
NULL
;
}
src/pcm_byteswap.h
View file @
ece6037a
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_PCM_BYTESWAP_H
#define MPD_PCM_BYTESWAP_H
#include "audio_format.h"
#include <stdint.h>
#include <stddef.h>
...
...
@@ -47,4 +49,19 @@ const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer,
const
int32_t
*
pcm_byteswap_32
(
struct
pcm_buffer
*
buffer
,
const
int32_t
*
src
,
size_t
len
);
/**
* Changes the endianness of PCM data.
*
* @param buffer the destination pcm_buffer object
* @param format the sample format (both input and output)
* @param src the source PCM buffer
* @param src_size the number of bytes in #src
* @return the destination buffer, or NULL if the sample format is not
* supported
*/
G_GNUC_MALLOC
const
void
*
pcm_byteswap
(
struct
pcm_buffer
*
buffer
,
enum
sample_format
format
,
const
void
*
src
,
size_t
size
);
#endif
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