pcm_byteswap: add function with sample_format overload
This commit is contained in:
parent
bea678a7cd
commit
ece6037a1e
@ -68,3 +68,29 @@ const int32_t *pcm_byteswap_32(struct pcm_buffer *buffer,
|
|||||||
|
|
||||||
return buf;
|
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;
|
||||||
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#ifndef MPD_PCM_BYTESWAP_H
|
#ifndef MPD_PCM_BYTESWAP_H
|
||||||
#define MPD_PCM_BYTESWAP_H
|
#define MPD_PCM_BYTESWAP_H
|
||||||
|
|
||||||
|
#include "audio_format.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.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 *pcm_byteswap_32(struct pcm_buffer *buffer,
|
||||||
const int32_t *src, size_t len);
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user