diff options
author | Max Kellermann <max@duempel.org> | 2012-03-27 01:01:16 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-03-27 01:22:50 +0200 |
commit | ddd4f675a2d42b0c8156e03bf3e93f39df2fe609 (patch) | |
tree | 248c44242b11e721eeb03fcb74c601fd12fdec39 /src/pcm_export.c | |
parent | d271dd2cce79d1473f43f7ad7e6815b74617dfe3 (diff) | |
download | mpd-ddd4f675a2d42b0c8156e03bf3e93f39df2fe609.tar.gz mpd-ddd4f675a2d42b0c8156e03bf3e93f39df2fe609.tar.xz mpd-ddd4f675a2d42b0c8156e03bf3e93f39df2fe609.zip |
pcm_export: implement 24 to 32 bit conversion
For 32 bit DSD-over-USB support.
Diffstat (limited to '')
-rw-r--r-- | src/pcm_export.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/pcm_export.c b/src/pcm_export.c index 66ed6d351..dbd9f2e8e 100644 --- a/src/pcm_export.c +++ b/src/pcm_export.c @@ -41,7 +41,7 @@ void pcm_export_deinit(struct pcm_export_state *state) void pcm_export_open(struct pcm_export_state *state, enum sample_format sample_format, unsigned channels, - bool dsd_usb, bool pack, bool reverse_endian) + bool dsd_usb, bool shift8, bool pack, bool reverse_endian) { assert(audio_valid_sample_format(sample_format)); assert(!dsd_usb || audio_valid_channel_count(channels)); @@ -53,8 +53,11 @@ pcm_export_open(struct pcm_export_state *state, samples are stuffed inside fake 24 bit samples */ sample_format = SAMPLE_FORMAT_S24_P32; + state->shift8 = shift8 && sample_format == SAMPLE_FORMAT_S24_P32; state->pack24 = pack && (sample_format == SAMPLE_FORMAT_S24_P32 || sample_format == SAMPLE_FORMAT_DSD_OVER_USB); + assert(!state->shift8 || !state->pack24); + state->reverse_endian = 0; if (reverse_endian) { size_t sample_size = state->pack24 @@ -90,8 +93,21 @@ pcm_export(struct pcm_export_state *state, const void *data, size_t size, data = dest; size = dest_size; + } else if (state->shift8) { + assert(size % 4 == 0); + + const uint8_t *src8 = data, *src_end8 = src8 + size; + const uint32_t *src = (const uint32_t *)src8; + const uint32_t *const src_end = (const uint32_t *)src_end8; + + uint32_t *dest = pcm_buffer_get(&state->pack_buffer, size); + data = dest; + + while (src < src_end) + *dest++ = *src++ << 8; } + if (state->reverse_endian > 0) { assert(state->reverse_endian >= 2); |