aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-22 06:58:08 +0200
committerMax Kellermann <max@duempel.org>2014-08-22 06:58:08 +0200
commitd8782ce5fd08a2fb7b10ba9eff40079907511402 (patch)
treede926f46d01a8f792e72bbf02ecbae820a21133c /src/decoder/plugins
parentdedc2986c69967793bddecb5af41d2021e0af87f (diff)
downloadmpd-d8782ce5fd08a2fb7b10ba9eff40079907511402.tar.gz
mpd-d8782ce5fd08a2fb7b10ba9eff40079907511402.tar.xz
mpd-d8782ce5fd08a2fb7b10ba9eff40079907511402.zip
decoder/dsf: simplify dsf_to_pcm_order()
Don't pass the buffer size to the function, as it's known at compile time. Use "restrict" on the pointer arguments, and merge the two loops, which allows the compiler to optimize this loop with a few SSE2 instructions.
Diffstat (limited to '')
-rw-r--r--src/decoder/plugins/DsfDecoderPlugin.cxx15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx
index 98538a842..8c6c3a03d 100644
--- a/src/decoder/plugins/DsfDecoderPlugin.cxx
+++ b/src/decoder/plugins/DsfDecoderPlugin.cxx
@@ -195,16 +195,11 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
* order.
*/
static void
-dsf_to_pcm_order(uint8_t *dest, const uint8_t *src, size_t nrbytes)
+dsf_to_pcm_order(uint8_t *gcc_restrict dest, const uint8_t *gcc_restrict src)
{
- for (size_t i = 0, j = 0; i < nrbytes; i += 2) {
- dest[i] = src[j];
- j++;
- }
-
- for (size_t i = 1, j = 0; i < nrbytes; i += 2) {
- dest[i] = src[DSF_BLOCK_SIZE + j];
- j++;
+ for (size_t i = 0; i < DSF_BLOCK_SIZE; ++i) {
+ dest[2 * i] = src[i];
+ dest[2 * i + 1] = src[DSF_BLOCK_SIZE + i];
}
}
@@ -236,7 +231,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
bit_reverse_buffer(buffer, buffer + block_size);
uint8_t interleaved_buffer[DSF_BLOCK_SIZE * 2];
- dsf_to_pcm_order(interleaved_buffer, buffer, block_size);
+ dsf_to_pcm_order(interleaved_buffer, buffer);
const auto cmd = decoder_data(decoder, is,
interleaved_buffer, block_size,